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

Home -> Community -> Usenet -> c.d.o.server -> Re: Exiting PL/SQL

Re: Exiting PL/SQL

From: Karsten Schmidt <groups_at_karsten-schmidt.com>
Date: 9 Jun 2004 20:48:37 -0700
Message-ID: <c6711ac4.0406091948.5427b1b1@posting.google.com>


"Gordon" <gordon_t_wu_at_hotmail.com> wrote in message news:<9nFxc.368$Ny6.1046_at_mencken.net.nih.gov>...
> "srivenu" <srivenu_at_hotmail.com> wrote in message
> news:1a68177.0406082158.3c7e097d_at_posting.google.com...
> > You can exit SQL*PLUS with "exit [value]" command and the exit command
> > will return the [value] to the OS.
> > $ sqlplus "/ as sysdba"
> > SQL> exit 10
> > $ echo $?
> > 10
> >
> > You can also use this for exiting from PL/SQL
> > Put this in a file x.sql
> >
> > whenever sqlerror exit 100
> > exec dbms_lock.sleep(30);
> >
> > $ sqlplus "/ as sysdba"
> > SQL> @x.sql
> > ^CBEGIN dbms_lock.sleep(30); END;
> >
> > *
> > ERROR at line 1:
> > ORA-01013: user requested cancel of current operation
> >
> > $ echo $?
> > 100
> >
> > regards
> > Srivenu
>
> Thank you Srivenu,
>
> Now my code works, but I have noticed something rather interesting.
> I have wrote my code to return 0 upon sucessful execution and -100 upon
> exception
>
> WHENEVER SQLERROR EXIT -100 ROLLBACK;
> BEGIN
> .....
> END;
> /
>
> EXIT 0; -- sucessful execution.
>
> Now: when the code executes without errors, 0 is always returned. When an
> error has occured, instead of -100, a random positive number is returned.
> Strange..., I wonder why.

return codes are unsigned byte on the OS level, so -100 would never work. why you get random numbers i cannot explain, i would expect you always get -100%255

Karsten Received on Wed Jun 09 2004 - 22:48:37 CDT

Original text of this message

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