The SQLCA Data Structure

The SQLCA data structure for OpenESQL and the DB2 ECM is shown below:

 01 SQLCA.
     05  SQLCAID         PIC X(8)         VALUE "SQLCA   ".
     05  SQLCABC         PIC S9(9) COMP-5 VALUE 136.
     05  SQLCODE         PIC S9(9) COMP-5 VALUE 0.
     05  SQLERRM.
         49  SQLERRML    PIC S9(4) COMP-5.
         49  SQLERRMC    PIC X(70).
     05  SQLERRP         PIC X(8).
     05  SQLERRD         PIC S9(9) COMP-5 OCCURS 6 VALUE 0.
     05  SQLWARN.
         10  SQLWARN0    PIC X.
         10  SQLWARN1    PIC X.
         10  SQLWARN2    PIC X.
         10  SQLWARN3    PIC X.
         10  SQLWARN4    PIC X.
         10  SQLWARN5    PIC X.
         10  SQLWARN6    PIC X.
         10  SQLWARN7    PIC X.
     05  SQLEXT.
         10  SQLWARN8    PIC X.
         10  SQLWARN9    PIC X.
         10  SQLWARN10   PIC X.
         10  SQLWARNA    PIC X REDEFINES SQLWARN10.
     05  SQLSTATE    PIC X(5).

The table below describes the contents of the SQLCA data structure:

Field Contents
SQLCAID The text string "SQLCA".
SQLCABC The length of the SQLCA data structure.
SQLCODE The status code for the last-run SQL statement:
   
SQLERRML The length of the error message in SQLERRMC (0–70).
SQLERRMC Error message text. Error messages longer than 70 bytes are truncated.
SQLERRP Reserved (diagnostic information).
SQLERRD An array of six integer status codes (those not listed below are reserved):
SQLERRD(1) SQL server error number.
SQLERRD(2) SQL server severity.
SQLERRD(3) The number of rows affected.
SQLWARN Eight warning flags, each containing a blank or "W" (those not listed below are reserved): A warning flag will be set if SQLCODE contains a value of +1:
SQLWARN0 A summary of all warning fields. Blank means there are no warnings.
SQLWARN1 "W" indicates that data was truncated on output to a character host variable.
SQLWARN2 "W" indicates that a null value exists, but no indicator variable was provided.
SQLWARN3 "W" indicates that the number of columns is less than the number of host variables or that the number of host variables provided does not match the number of parameter markers in the statement. The lower of the two numbers has been used.
SQLWARN4 "W" indicates a singleton select that returns more than one row (only the first row is returned).
FILLER Reserved.
SQLSTATE Status indicator for the last-run SQL statement.
Note: The Oracle, Sybase, and Informix versions of the SQLCA all use SQLCODE, SQLERRML, SQLERRMC, and SQLWARN. The sizes and the positions of these fields can differ among the precompilers.