2012-04-10 80 views

回答

3

重新认识作为ODI建议肯定会工作。通过稍微不同的做法,您可以获得相同的效果。

begin 
    var := true; 

    ... your code that can cause exceptions... 

    var := false; --var set to false unless an exception was encountered 
exception 
    when exception1 then 
    ... 
    when exception2 then 
    ... 
end; 
+0

感谢约翰,这真是太棒了。 – Vaandu 2012-04-11 04:58:59

1

你可以用子块做到这一点,首先设置值,然后重新抛出异常来处理它:

begin 
    begin 
    -- do something 
    exception 
     when others then 
     var = true; 
     raise; -- re-raise the current exception for further exception handling 
    end; 
    exception 
    when excep1 then 
     -- do something 
    when excep2 then 
     -- do something 
    end; 
+0

感谢您的答复,ODI :) – Vaandu 2012-04-11 04:59:47

1

另一种方法是把它放在另一个程序,例如:

declare 
    procedure common_exception_routine is 
    begin 
    var = true; 
    end common_exception_routine; 
begin 
    ... 
exception 
    when excep1 then 
    common_exception_routine; 
    when excep2 then 
    common_exception_routine; 
end; 
+0

谢谢Jeffrey :) – Vaandu 2012-04-11 05:00:49

相关问题