SQL Error Checking

The EXECSQL WHENEVER statement is not valid for REXX. You must check either the SQLCODE or SQLSTATE value for errors or warnings after each EXECSQL call. Additionally, after an EXECSQL call the REXX RC special variable is set to a return code. Valid return codes are:

0
No SQL warning or error occurred.
+1
An SQL warning occurred.
-1
An SQL error occurred.
-3
Invalid or unsupported token found after DSNREXX.

For example:

SSID = "DB2T"
ADDRESS MVS "SUBCOM DSNREXX"
IF RC THEN S_RC = RXSUBCOM('ADD','DSNREXX','DSNREXX')
ADDRESS DSNREXX "CONNECT" SSID
IF RC /= 0 THEN DO
   SAY "FAILURE TO CONNECT TO DATABASE"  
   EXIT 8
END

If you try to use Micro Focus DSNREXX with any DBMS other than DB2 LUW or SQL Server the return code of -1 is returned (SQL error) after the DSNREXX "CONNECT" statement.

You can check REXX SQLCA variables for more information about the SQL error or warning. You do not need to define these variables:
  • SQLCODE
  • SQLERRMC
  • SQLERRP
  • SQLERRD.1
  • SQLERRD.2
  • SQLERRD.3
  • SQLERRD.4
  • SQLERRD.5
  • SQLERRD.6
  • SQLWARN.0
  • SQLWARN.1
  • SQLWARN.2
  • SQLWARN.3
  • SQLWARN.4
  • SQLWARN.5
  • SQLWARN.6
  • SQLWARN.7
  • SQLWARN.8
  • SQLWARN.9
  • SQLWARN.10
  • SQLSTATE