1、oracle的open for fetch语法
oracle的open for fetch语法
open for fetch是一种游标循环方式。
open c1 for '动态sql' [using];
loop
fetch c1 into [table]
exit when c1%notfound;
...
end loop;
使用示例:
declare
type cur_model_type is ref cursor;
c1 cur_model_type;
v_task_code tab_test.task_code%type;
v_draw_type tab_test.draw_type%type;
begin
open c1 for 'select task_code,draw_type from tab_test where rownum = 1';
loop
fetch c1 into v_task_code,v_draw_type;--每次循环出来接收的参数
exit when c1%notfound;--没有记录时停止
dbms_output.put_line('v_task_code:'||v_task_code||',v_draw_type:'||v_draw_type);
end loop;
close c1;
end;