1) 执行代码:
declare
cursor s is select priv from test2;
cur_tst varchar2(1);
begin
open s;
loop
exit when s%notfound;
fetch s into cur_tst;
--exit when s%notfound;
dbms_output.put_line(cur_tst);
end loop;
close s;
exception
when others then
dbms_output.put_line('222222');
end;
执行结果如下:
2) 原因如下:
游标是要先fetch才能有游标属性的,不应该还没有fetch, 就用%notfound.