REXX applications can request more information about SQL error codes by using the DSNTIAR subroutine or issuing a GET DIAGNOSTICS statement.
Procedure
Db2 does not support the SQL WHENEVER statement in a REXX program. To handle SQL errors and warnings, use the following methods:
- To test for SQL errors or warnings, test the SQLCODE or SQLSTATE value and the SQLWARN. values after each EXECSQL call. This method does not detect errors in the REXX interface to Db2.
- To test for SQL errors or warnings or errors or warnings from the REXX interface to Db2, test the REXX RC variable after each EXECSQL call.
The following table lists the values of the RC variable.
You can also use the REXX SIGNAL ON ERROR and SIGNAL ON FAILURE keyword instructions to detect negative values of the RC variable and transfer control to an error routine.