Re: Simple Error trapping in SQLplus in Oracle

From: Mark D Powell <Mark.Powell_at_eds.com>
Date: 16 May 2003 06:37:14 -0700
Message-ID: <2687bb95.0305160537.71b6c167_at_posting.google.com>


pentzol_at_hotmail.com (Lourens Pentz) wrote in message news:<4baec153.0305151544.10b4bb05_at_posting.google.com>...
> Hi,
>
> I do the following using ksh - scripting on an Oracle database:
>
> +++++++++++++++++++
> sqlplus username/PASS_at_Database << EOF
>
>
> update table1 set field1 = 'xxx' where field1 = 'yyyy';
>
>
>
> insert into table2
> (field1,
> field2,
> field3)
> values ('value1',
> 'value2',
> 'value3);
>
>
>
> insert into table3
> (field1,
> field2,
> field3)
> values ('value1',
> 'value2',
> 'value3);
>
>
> insert into table4
> (field1,
> field2,
> field3)
> values ('value1',
> 'value2',
> 'value3);
>
>
> commit;
> exit;
> EOF
>
>
> +++++++++++++++++++
>
> The question is : How can I do an error trap on each SQL statement, so
> that the moment it generates an error (doesn't matter what), it does a
> rollback and exit out of the sqlplus ??
>
> Cheers
> Lourens

See the SQLPlus manual for "whenever sqlerror exit FAILURE"

HTH -- Mark D Powell -- Received on Fri May 16 2003 - 15:37:14 CEST

Original text of this message