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: exit status of sqlplus???

Re: exit status of sqlplus???

From: Raoul J.M. Riley <riley_at_ascending.com>
Date: 1997/02/21
Message-ID: <330DF944.6F9B@ascending.com>#1/1

Wang Chun wrote:
>
> Hi,
>
> I tried to run a sql script using sqlplus, however, I could not figure out
> how to check the exit status at the unix shell level of a certain sql script
> to see whether the sql script is successful or failure.
>
> for example:
>
> shell>sqlplus @my_sql_script
>
> ...
>
> shell> (as when sqlplus exits, it always give me the exit code 0)
>
> Any suggestion?
>
> Thanks in advance!

In a SQL*Plus script, every SQL statement generates a SQL error code, zero for success, non-zero for failure. To pass this code on to the calling UNIX shell script, the SQL*Plus script must say 'exit sql.sqlcode' at the end.

Sql.sqlcode only refers to the last SQL statement executed in a SQL*Plus script. It might be more effective to use the statement 'whenever sqlerror exit sql.sqlcode' at the beginning of SQL*Plus scripts that contain multiple SQL statements. That way, if any of the SQL statements generate an error, SQL*Plus will quit processing the script, and return the SQL error code to the calling UNIX shell. Received on Fri Feb 21 1997 - 00:00:00 CST

Original text of this message

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