Re: How to trap error in sqlplus?

From: <sybrandb_at_yahoo.com>
Date: 12 Jun 2003 00:28:23 -0700
Message-ID: <a1d154f4.0306112328.2e7e8b6c_at_posting.google.com>


pmahale_at_yahoo.com (Prasad Mahale) wrote in message news:<44a6df49.0306111309.7c80316a_at_posting.google.com>...
> Hi All,
> I am not an expert in oracle but trying to do something like this -
>
> Here are the lines from the shell script -
>
> ..
> ..
> $ORACLE_HOME/bin/sqlplus -S $O_USER/$O_PASSWORD << EOF
> set serveroutput on
> set echo off
> set feedback off
> set heading off
> spool $SPOOLFILE
> EXECUTE procedure01;
> EXECUTE procedure02;
> spool off
> exit
> EOF
>
> ..
> ..
>
> What happens is, when procedure01 fails, it goes ahead and executes
> procedure02. I want Oracle to exit if procedure01 fails. What is the
> easiest way to do this?
>
> Thanks in advance.
>
> prasad

whenever sqlerror exit failure before callinb the procedures. Better still : learning pl/sql and use
begin
procedure01;
procedure02;
end;
If anything in the anonymous block fails, the entire block will fail.

The pl/sql manual has a section on error trapping the sql*plus manual discusses the whenever command.

Sybrand Bakker
Senior Oracle DBA Received on Thu Jun 12 2003 - 09:28:23 CEST

Original text of this message