Re: PL/SQL beginner

  • From: Jared Still <jkstill@xxxxxxxxx>
  • To: Lee.Robertson@xxxxxxxxxx
  • Date: Thu, 5 Feb 2009 12:52:12 -0800

On Thu, Feb 5, 2009 at 9:08 AM, Robertson Lee - lerobe <
Lee.Robertson@xxxxxxxxxx> wrote:

> Ideally I would also like to report back to the calling SQL*Plus script the
> errors from the failed PL/SQL.
>
> I cannot re-engineer, I just need to make what is already there work if it
> is at all possible.
>
>

As Dan has pointed out, sqlplus does not have a robust error handling
environment.

One thing that is possible to do with sqplus, is to return an error code to
the OS on failure.

12:49:52 SQL whenever sqlerror exit sql.sqlcode
12:49:52 SQL
12:49:52 SQL begin
12:49:52   2          raise_application_error(-20001,'oops');
12:49:52   3  end;
12:49:52   4  /
begin
*
ERROR at line 1:
ORA-20001: oops
ORA-06512: at line 2


Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0
- Production
With the Partitioning, Oracle Label Security and Data Mining options

$> echo $?
33

What this would allow you to do is call the stored procedures via sqlplus
using
a shell script as a driver, and checking the return codes.

If you really need this level of control however, something like Perl with
DBI would
probably be a better choice.


Jared Still
Certifiable Oracle DBA and Part Time Perl Evangelist

Other related posts: