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: Trapping errors in SQLPLUS scripts

Re: Trapping errors in SQLPLUS scripts

From: Jonathan Gennick <gennick_at_worldnet.att.net>
Date: Wed, 08 Jul 1998 18:45:09 GMT
Message-ID: <6o0end$24d@bgtnsc03.worldnet.att.net>


On Wed, 8 Jul 1998 16:07:29 +0100 (BST), tonyh_at_gmap.leeds.ac.uk (Tony Howard) wrote:

>Is there any way to trap or save error messages from a sql script.
>I want to create a user (with a tablespace and datafile) from a script,
>and know if it fails for any reason

You can spool the output from the script to a text file. You can also look at the status returned by SQL*Plus. For example:

SET ECHO ON
SPOOL c:\create_output.lis
create user yadda identified by yadda_yadda; SPOOL OFF The above will get you the results of the create user command into the text file named create_output.lis.

If you are writing a Unix shell script, and want to know whether or not an error occurred, use the WHENEVER command.

        WHENEVER SQLERROR EXIT 1 Put that first in your script, and any SQL error will cause SQL*Plus to exit and return a status of 1.

Jonathan Received on Wed Jul 08 1998 - 13:45:09 CDT

Original text of this message

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