【发布时间】:2014-07-29 01:03:07
【问题描述】:
我们能否在异常中引发异常,例如在WHEN OTHERS 异常中引发RAISE my_exception?
此外,我试图了解以下两种情况下的输出: (请注意,唯一的区别是异常的顺序)
场景 1
DECLARE
lc_exception Exception;
var1 number;
BEGIN
select 1
into var1
from dual
where 1=2;
EXCEPTION
when lc_exception then
dbms_output.put_line('This is my exception');
when no_data_found then
raise lc_exception;
when others then
dbms_output.put_line('There could be some other exception');
END;
场景 2
DECLARE
lc_exception Exception;
var1 number;
BEGIN
select 1
into var1
from dual
where 1=2;
EXCEPTION
when no_data_found then
raise lc_exception;
when lc_exception then
dbms_output.put_line('This is my exception');
when others then
dbms_output.put_line('There could be some other exception');
END;
【问题讨论】:
-
是的,您可以在异常处理程序中引发另一个异常。
-
请您也回答上述2个场景
-
@NoobEditor --> 在提出我的问题之前,我已经完成了上述线程。我相信我的问题与上述线程有点不同(如果你经历了场景)。无论如何,非常感谢您的帮助.... :)