Re: Grrr! How do you make sqlplus exit on a syntax error!

From: Daniel Morgan <dmorgan_at_exesolutions.com>
Date: Tue, 08 Oct 2002 23:03:48 GMT
Message-ID: <3DA36433.C3F4BA55_at_exesolutions.com>


Peter Lacey wrote:

> I want to call various sql scripts from within a perl script and know
> if they succeeded or failed. After a series of setbacks I have the
> following code preceeding the SQL itself:
>
> WHENEVER OSERROR EXIT 255
> WHENEVER SQLERROR EXIT 255
> CONNECT &1/&2_at_&3
> BEGIN
> NULL;
> END;
> /
> WHENEVER SQLERROR EXIT SQL.SQLCODE
>
> The 6 silly lines in the middle were needed simply to get sqlplus to
> exit on a failed login. However, if the SQL that follows contains a
> -syntax- error, nothing happens, sqlplus just keeps running the SQL.
> So the question is, where is the Oracle equivalent of WHENEVER
> SYNTAXERROR EXIT (whatever). Be aware that there are tens of files
> each thousands of lines long. A good answer would allow me to modify
> each file in just one place.
>
> <rant>Who wrote this thing, anyway? Hasn't sqlplus been around for
> 100 years? Hasn't anyone ever needed to simply exit sqlplus when
> something -anything- goes wrong?</rant>

What's everyone whining about?

Just use an anonymous block.

BEGIN
   your SQL statement's here
END;
/

Daniel Morgan Received on Wed Oct 09 2002 - 01:03:48 CEST

Original text of this message