create or replace
PROCEDURE IFTEST AS 
type cursortest is ref cursor;
  testcur cursortest;
  number2 number(7,2);
BEGIN
  open testcur for select sal from emp;
  if testcur%rowcount=0 then     为什么长度为零 呢
   dbms_output.put_line('not data foun');
   else 
   loop
    fetch testcur into number2;
     exit when testcur%notfound;
     dbms_output.put_line(number2);
     end loop;
     end if;
     close testcur;
END IFTEST;

解决方案 »

  1.   

    testcur%rowcount就是判断游标大小的,
    testcur%rowcount=0 说明select sal from emp没有取到值
      

  2.   

    if testcur%rowcount=0 then 为什么长度为零 呢这不是长度 是判断游标从游标获取的记录数  为0则意思是还没有从游标获取记录
      

  3.   

    open testcur for select sal from emp;
      if testcur%rowcount=0 then 为什么长度为零 呢
    你还没有提取游标肯定是0咯你这样可以用exception来出来嘛
    exception when no_data_found then
    dbms_output.put_line('not data foun');
      

  4.   

    为0则意思是还没有从游标获取记录  或者 游标后面的SQL没有记录
      

  5.   


    --------你这样修改就行了,前面的if是多余的
    create or replace PROCEDURE IFTEST AS
      type cursortest is ref cursor;
      testcur cursortest;
      number2 number(7, 2);
    BEGIN
      open testcur for
        select sal from emp;
      loop
        fetch testcur
          into number2;
        exit when testcur%notfound;
        dbms_output.put_line(number2);
      end loop;
      close testcur;
    END IFTEST;