Was this helpful?
Contents of the SQLCA
One of the results of issuing the include sqlca statement is the declaration of the SQLCA structure, which you can use for error handling in the context of database statements. You need to issue the statement only once per source file because it generates an extern structure declaration.
The structure declaration for the SQLCA is:
typedef struct {
char sqlcaid[8];
 long sqlcabc;
 long sqlcode;
 struct {
   short sqlerrml;
   char sqlerrmc[70];
 } sqlerrm;
 char sqlerrp[8];
 long sqlerrd[6];
 struct {
   char sqlwarn0;
   char sqlwarn1;
   char sqlwarn2;
   char sqlwarn3;
   char sqlwarn4;
   char sqlwarn5;
   char sqlwarn6;
   char sqlwarn7;
 } sqlwarn;
 char sqlext[8];
 } IISQLCA;
extern IISQLCA sqlca;
The nested structure sqlerrm is a varying length character string consisting of the two variables sqlerrml and sqlerrmc described in the SQL Reference Guide. For a full description of all the SQLCA structure members, see the SQL Reference Guide.
The SQLCA is initialized at load-time. The sqlcaid and sqlcabc fields are initialized to the string SQLCA and the constant 136, respectively.
Note:  The preprocessor is not aware of the structure declaration. Therefore, you cannot use members of the structure in an embedded SQL statement.
For example, the following statement, attempting to insert the string SQLCA into a table, generates an error:
exec sql insert into employee (ename)
 /* This statement is illegal */
    values (:sqlca.sqlcaid);
Note that the string-valued fields in the SQLCA are not null-terminated. Consequently, if you copy their values into other C variables, you must add the C null character afterwards.
All modules linked together share the same SQLCA.
Last modified date: 01/30/2023