create or replace function f_cursor_use
return integer
as
v_getString varchar2(200);
cursor mycursor is select b.cut from b;
begin
open mycursor;
loop
fetch mycursor into v_getString;
/* execute immediate v_sql;*/
exit when mycursor%notfound;
dbms_output.put_line(v_getString);
/*如果放exit里面的话输出3次,其中第三次输出的时候,其实mycursor已经没有值了。
相反的 如果exit放在exit后面时,第三次mycursor没有值了,直接跳出循环*/
end loop;
close mycursor;
return 1;
exception
when others then
return 0;
end f_cursor_use;
游标中的fetch,其实就是一条一条的读,不是循环。顺序读取
浙公网安备 33010602011771号