cursor cus1 IS select * from table1 where id>10
    v_count number:=0;
begin
    open c;
    loop
        fetch c into ...;
        exit when c%notfound;
        v_count:=v_count+1;
        ....
    end loop
    if v_count=0 then 
        --为零是做什么写在这里
    end if;
..end ;
另一方法:    v_count number;
begin    select count(*) into v_count from table1 where id>10;
   if v_count=0 then 
       --为零处理
    else   end if;
 ..
 end ;

解决方案 »

  1.   

    %rowcount是指明总共取了多少行数据,
    可是如果没渠道一条数据是不是cus1%rowcount=0呢?我试了一下好像不是。
    我判断 if cus1%rowcount=0 then
          dbms_output.put_line('无记录!');
        end if;
    而程序没有打出‘无记录’!而是执行了EXCEPTION里的!
    那么如果没有取到数据cus1%rowcount是什么呢?难道是null??
      

  2.   

    cus1%rowcount=null我也试了,还是执行到EXCEPTION里了!