我正在编写一个打开 2 个游标的过程,并且需要为每个游标执行一些逻辑,但如果no_data_found
. 如果我不处理它,则 fetch 插入空值,如果我抛出异常,它会忽略第二部分。
代码:
create or replace procedure pro_name(param1,param2....)
as
var1
var2
TYPE cur_typ IS REF CURSOR;
c cur_typ;
etc...
begin
sql_str := 'select from ' || param1 || 'where some_cond..';
open c for sql_str;
loop
fetch c into v1, v2 , v3;
DO STUFF...
end loop;
commit;
-- go all over again with different table
sql_str2 := 'select from ' || param2 || 'where some_cond..';
open c2 for sql_str2;
loop
fetch c into v1a, v2a , v3a;
DO STUFF...
end loop;
commit;
end;
我应该在哪里放置错误处理?