A SQLCA structure can be used in conjunction with CTBDIAG to retrieve Client-Library and server error and informational messages.
A SQLCA structure is defined as follows:
DCL 01 SQLCA_MSG, 05 SQLCAID CHAR(8), 05 SQLCABC FIXED BIN(31), 05 SQLCODE FIXED BIN(31), 05 SQLERRM, 49 SQLERRML FIXED BIN(31), 49 SQLERRMC CHAR(256), 05 SQLERRP CHAR(8), 05 SQLERRD OCCURS 6 TIMES FIXED BIN(31), 05 SQLWARN, 10 SQLWARN0 CHAR(1), 10SQLWARN1 CHAR(1), 10SQLWARN2 CHAR(1), 10 S QLWARN3 CHAR(1), 10 SQLWARN4 CHAR(1), 10 SQLWARN5 CHAR(1), 10 SQLWARN6 CHAR(1), 10 SQLWARN7 CHAR(1), 05 SQLEXT CHAR(8);
SQLCAID is “SQLCA” (This value is automatically provided).
SQLCABC is ignored.
SQLCODE is the server or Client-Library message number. For information on how Client-Library maps message numbers to SQLCODE, see “SQLCODE structure”. For a list of gateway messages, see the Mainframe Connect Client Option Installation and Administration Guide shipped with this product.
SQLERRML is the length of the actual message text (not the length of the text placed in SQLERRMC).
SQLERRMC is the null-terminated text of the message. If the message is too long for the array, Client-Library truncates it before appending the null terminator.
SQLERRP is the first eight characters of the stored procedure being executed at the time of the error.
SQLERRD is the number of rows successfully inserted, updated, or deleted before the error occurred.
SQLWARN is an array of warnings:
If SQLWARN0 is blank, all other SQLWARN variables are blank. If SQLWARN0 is not blank, at least one other SQLWARN variable is set to W.
If SQLWARN1 is W, Client-Library truncated at least one column’s value when storing it into a mainframe variable.
If SQLWARN2 is W, at least one null value was eliminated from the argument set of a function.
If SQLWARN3 is W, the number of mainframe variables specified in the into clause of a select statement is not equal to the number of result columns.
If SQLWARN4 is W, a dynamic SQL update or delete statement did not include a where clause.
If SQLWARN5 is W, a server conversion or truncation error occurred. SQLEXT is ignored.