A SQLCA structure can be used in conjunction with ct_diag to retrieve Client-Library and server error and informational messages.
A SQLCA structure is defined as follows:
/* SQL Communication Area - SQLCA */
typedef struct sqlca { unsigned char sqlcaid[8]; /* Eyecatcher = ‘SQLCA’ */ long sqlcabc; /* SQLCA size in bytes = 136 */ long sqlcode; /* SQL return code */ short sqlerrml; /* Length for SQLERRMC */ unsigned char sqlerrmc[256]; /* Error message tokens */ unsigned char sqlerrp[8]; /* Diagnostic information */ long sqlerrd[6]; /* Diagnostic information */ unsigned char sqlwarn[8]; /* Warning flags */ unsigned char sqlext[8]; /* Reserved */ } SQLCA;
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 and Server Option Messages and Codes 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, if any, 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.