Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Exit from PL/SQL Exception Block
On Thu, 13 Aug 1998 13:14:12 GMT, Richard Elliott
<Richard.A.Elliott_at_wgp.twc.com> wrote:
>I have a large number of PL/SQL programs that all have EXCEPTION blocks
>in them. I want to exit with a specific return code any time the
>exception block is entered. The "whenever sqlerror exit 99" stmt does
>not seem to work if you have an exception block. How can I exit from the
>exception block. Thanks in advance for your help. Reply to E:Mail or
>news group. Thanks !
You need to do a raise_application_error from within the exception block. That raises the error to the SQL*Plus level, where it is trapped by WHENEVER. for example:
begin
...
exception
when others then
raise_application_error(-20000,'Your message goes
here.');
end;
![]() |
![]() |