Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exception / Error handlers in DB2?

Status
Not open for further replies.

kristo5747

Programmer
Mar 16, 2011
41
US
I have a bunch of SQL scripts (with shell script wrappers) to unload data like so

Code:
EXPORT TO /tmp/out.csv OF DEL MODIFIED BY NOCHARDEL  COLDEL, DATESISO 
    MESSAGES /tmp/out.msg SELECT WIDGETID
        ...

I want to add an error handler to the script the way Oracle does it

Code:
WHENEVER SQLERROR EXIT FAILURE;
    SPOOL  /tmp/out.csv;
    SELECT WIDGETID...
    SPOOL OFF;

According to DB2's documentation, this can be done in stored procedures, C, Perl, REXX....nothing else.

Has anyone done this in SQL scripts? Can you provide pointers?

Code:
Running  DB2/LINUXX8664 9.7.2.
 
According to DB2's documentation, this can be done in stored procedures, C, Perl, REXX....nothing else.

Suggest you believe the documentation (assuming this is the IBM documentation for the proper release of DB2). . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top