问题
How can I throw cached exception in PL/SQL?
For example I have procedure, where I catch all exceptions:
EXCEPTION
WHEN OTHERS THEN
rollback;
and then I want to throw catched exception to procedure caller.
Thanks in advance!
回答1:
Just add raise;
:
EXCEPTION
WHEN OTHERS THEN
rollback;
raise;
回答2:
To re-raise the exception, just use
raise;
To define a custom application error, look at raise_application_error, e.g.
raise_application_error(-20001, 'Warp core implosion imminent', true);
It's worth bearing in mind that due to what I've just decided to call the Exception Handling Uncertainty Principle, there is always a trade-off between reporting the full exception details and doing something about the exception.
来源:https://stackoverflow.com/questions/38767142/pl-sql-raise-handled-exception