Description of SQLCA fields

For the most part, COBOL, C, PL/I, and assembler use the same names for the SQLCA fields, and Fortran uses different names. However, there is one instance where C, PL/I, and assembler names differ from COBOL.

The names in the following table are those provided by the SQL INCLUDE statement.

Table 1. Fields of SQLCA
PL/I Name
SQLCAID sqlcaid Not used. CHAR(8) An eye catcher for storage dumps, containing the text 'SQLCA'. The sixth byte is 'L' if line number information is returned from parsing a dynamic statement or a native SQL procedure. The sixth byte is not set when processing an external SQL procedure.
SQLCABC sqlcabc Not used. INTEGER Contains the length of the SQLCA: 136.
SQLCODE (See note 1) SQLCODE SQLCOD INTEGER Contains the SQL return code. (See note 2)
Successful execution (though there might have been warning messages).
Successful execution, but with a warning condition or other information.
Error condition.
(See note 3)
(See note 3)
SQLTXL SMALLINT Length indicator for SQLERRMC, in the range 0 through 70. 0 means that the value of SQLERRMC is not pertinent.
(See note 3)
(See note 3)
SQLTXT VARCHAR(70) Contains one or more tokens, separated by X'FF', that are substituted for variables in the descriptions of error conditions. It may contain truncated tokens. A message length of 70 bytes indicates a possible truncation.
SQLERRP sqlerrp SQLERP CHAR(8) Provides a product signature and, in the case of an error, diagnostic information such as the name of the module that detected the error. In all cases, the first three characters are 'DSN' for Db2 for z/OS®.
SQLERRD(1) sqlerrd[0] SQLERR(1) INTEGER For a sensitive static cursor, contains the number of rows in a result table when the cursor position is after the last row (that is, when SQLCODE is equal to +100).

On successful return from an SQL procedure, contains the return status value from the SQL procedure.

SQLERRD(1) can also contain an internal error code.

SQLERRD(2) sqlerrd[1] SQLERR(2) INTEGER For a sensitive static cursor, contains the number of rows in a result table when the cursor position is after the last row (that is, when SQLCODE is equal to +100).

SQLERRD(2) can also contain an internal error code.

SQLERRD(3) sqlerrd[2] SQLERR(3) INTEGER Contains the number of rows that qualified to be deleted, inserted, or updated after a DELETE, INSERT, UPDATE, or MERGE statement. The number excludes rows affected by triggers, referential integrity constraints, or inserted rows that are the result of processing a FOR PORTION OF clause for a BUSINESS_TIME period. For the OPEN of a cursor for a SELECT with a data change statement or for a SELECT INTO, SQLERRD(3) contains the number of rows affected by the embedded data change statement. The value is 0 if the SQL statement fails, indicating that all changes made in executing the statement canceled.

For a DELETE statement the value will be -1 if the operation is a mass delete from a table in a segmented table space and the DELETE statement did not include selection criteria. If the delete was against a view, neither the DELETE statement nor the definition of the view included selection criteria.

For a TRUNCATE statement, the value will be -1.

For a PREPARE statement, contains the estimated number of rows selected. If the number of rows is greater than 2,147,483,647, a value of 2,147,483,647 is returned.

For a REFRESH TABLE statement, SQLERRD(3) contains the number of rows inserted into the materialized query table.

For a rowset-oriented FETCH, contains the number of rows fetched.

SQLERRD(3) (continued)      

For SQLCODES -911 and -913, SQLERRD(3) contains the reason code for the timeout or deadlock.

When an error is encountered in parsing a dynamic statement, or when parsing, binding, or executing a native SQL procedure, SQLERRD(3) will contain the line number where the error was encountered. The sixth byte of SQLCAID must be 'L' for this to be a valid line number. This value will be meaningful only if the statement source contains new line control characters. This information is not returned for an external SQL procedure.

SQLERRD(4) sqlerrd[3] SQLERR(4) INTEGER Generally, contains timerons, a short floating-point value that indicates a rough relative estimate of resources required (See note 4). It does not reflect an estimate of the time required. When preparing a dynamically defined SQL statement, you can use this field as an indicator of the relative cost of the prepared SQL statement. For a particular statement, this number can vary with changes to the statistics in the catalog. It is also subject to change between releases of Db2 for z/OS.
SQLERRD(5) sqlerrd[4] SQLERR(5) INTEGER Contains the position or column of a syntax error for a PREPARE or EXECUTE IMMEDIATE statement.
SQLERRD(6) sqlerrd[5] SQLERR(6) INTEGER Contains an internal error code.
SQLWARN0 SQLWARN0 SQLWRN(0) CHAR(1) Contains a blank if no other indicator is set to a warning condition (that is, no other indicator contains a W or Z). Contains a W if at least one other indicator contains a W or Z.
SQLWARN1 SQLWARN1 SQLWRN(1) CHAR(1) Contains a W if the value of a string column was truncated when assigned to a host variable. Contains an N for non-scrollable cursors and S for scrollable cursors after the OPEN CURSOR or ALLOCATE CURSOR statement.
SQLWARN2 SQLWARN2 SQLWRN(2) CHAR(1) Contains a W if null values were eliminated from the argument of an aggregate function; not necessarily set to W for the MIN function because its results are not dependent on the elimination of null values.
SQLWARN3 SQLWARN3 SQLWRN(3) CHAR(1) Contains a W if the number of result columns is larger than the number of host variables. Contains a Z if fewer locators were provided in the ASSOCIATE LOCATORS statement than the stored procedure returned.
SQLWARN4 SQLWARN4 SQLWRN(4) CHAR(1) Contains a W if a prepared UPDATE or DELETE statement does not include a WHERE clause. For a scrollable cursor, contains a D for sensitive dynamic cursors, I for insensitive cursors, and S for sensitive static cursors after the OPEN CURSOR or ALLOCATE CURSOR statement; blank if cursor is not scrollable.
SQLWARN5 SQLWARN5 SQLWRN(5) CHAR(1) Contains a W if the SQL statement was not executed because it is not a valid SQL statement in Db2 for z/OS. Contains a character value of 1 (read only), 2 (read and delete), or 4 (read, delete, and update) to reflect capability of the cursor after the OPEN CURSOR or ALLOCATE CURSOR statement.
SQLWARN6 SQLWARN6 SQLWRN(6) CHAR(1) Contains a W if the addition of a month or year duration to a DATE or TIMESTAMP value results in an invalid day (for example, June 31). Indicates that the value of the day was changed to the last day of the month to make the result valid.
SQLWARN7 SQLWARN7 SQLWRN(7) CHAR(1) Contains a W if one or more nonzero digits were eliminated from the fractional part of a number used as the operand of a decimal multiply or divide operation.
SQLWARN8 SQLWARN8 SQLWRX(1) CHAR(1) Contains a W if a character that could not be converted was replaced with a substitute character. Contains a Y if there was an unsuccessful attempt to establish a trusted connection.
SQLWARN9 SQLWARN9 SQLWRX(2) CHAR(1) Contains a W if arithmetic exceptions were ignored during COUNT or COUNT_BIG processing. Contains a Z if the stored procedure returned multiple result sets.
SQLWARNA SQLWARNA SQLWRX(3) CHAR(1) Contains a W if at least one character field of the SQLCA or the SQLDA names or labels is invalid due to a character conversion error.
SQLSTATE sqlstate SQLSTT CHAR(5) Contains a return code for the outcome of the most recent execution of an SQL statement (See note 5).
  1. With the precompiler option STDSQL(YES) in effect, SQLCODE is replaced by SQLCADE in SQLCA.
  2. For the specific meanings of SQL return codes, see SQL codes.
  3. In COBOL, SQLERRM includes SQLERRML and SQLERRMC. In PL/I and C, the varying-length string SQLERRM is equivalent to SQLERRML prefixed to SQLERRMC. In assembler, the storage area SQLERRM is equivalent to SQLERRML and SQLERRMC. See the examples for the various host languages in The included SQLCA.
  4. The use of timerons may require special handling because they are floating-point values in an INTEGER array. In PL/I, for example, you could first copy the value into a BIN FIXED(31) based variable that coincides with a BIN FLOAT(24) variable.
  5. For a description of SQLSTATE values, see SQLSTATE values and common error codes.