Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Exit from PL/SQL Exception Block

Re: Exit from PL/SQL Exception Block

From: Jonathan Gennick <gennick_at_worldnet.att.net>
Date: 14 Aug 1998 02:52:19 GMT
Message-ID: <35d32b5a.12972255@netnews.worldnet.att.net>


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;



Jonathan Gennick
gennick_at_worldnet.att.net
http://home.att.net/~gennick
coauthor: Teach Yourself PL/SQL in 21 Days Brighten the corner where you are. Received on Thu Aug 13 1998 - 21:52:19 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US