为什么不用 %rowcount
%notfound倒是可以判断没有返回任何记录的

解决方案 »

  1.   

    TYPE refConsor IS REF CURSOR;   -- 定义游标(在数据更新时用到)
      cur_Cols refConsor;
      row_Cols 表%ROWTYPE; -- 字段列
    BEGIN
      OPEN cur_Cols FOR    -- 打开游标
            'SELECT * FROM 表名'   
      LOOP
        FETCH cur_Cols INTO row_Cols;
        EXIT WHEN cur_Cols%NOTFOUND;   -- 没有记录时退出循环
        -- 其它操作...  END LOOP;  
      CLOSE cur_Cols;
      dbms_output.put_line('成功更新.');
      

  2.   

    cursor c is select * from tablename ;
    begin
        open c;
        loop
            fetch c into 。;
            exit when c%notfound;
               dbms_output.put_line('what you want to output!');
        end loop;
        ..
    end;