永发信息网

oracle出现异常如何继续执行

答案:2  悬赏:40  手机版
解决时间 2021-02-20 15:36
  • 提问者网友:溺爱和你
  • 2021-02-19 19:21
create or replace procedure demo as

myex exception;

begin

begin

begin
for i in 1 .. 10 loop

if i = 5 then
raise myex;
end if;

dbms_output.put_line(i);

end loop;

exception
when others then
dbms_output.put_line('111er');

end;

end;
end demo;
最佳答案
  • 五星知识达人网友:未来江山和你
  • 2021-02-19 19:28
你的意思是, 要当发生异常 dbms_output.put_line('111er'); 以后, 循环继续执行?

create or replace procedure demo as
myex exception;
begin
begin
for i in 1 .. 10 loop

BEGIN
if i = 5 then
raise myex;
end if;
dbms_output.put_line(i);

exception
when others then
dbms_output.put_line('111er');
END;

end loop;

end;
end demo;
全部回答
  • 1楼网友:怀裏藏嬌
  • 2021-02-19 20:10
可能用异常处理 open cur_temp for vc_sql1; loop fetch cur_temp into vc_prcname, vc_prctype; exit when cur_temp%notfound; vc_sql2 := '。。。'; begin execute immediate vc_sql2; --这句代码有可能会执行出错,希望在执行出错时可以忽略该错误,继续往下循环,如何实现? exception when others then end; end loop; close cur_temp; 试试这样行不行。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯