Was this helpful?
Contents of the SQLCA
One of the results of issuing the include sqlca statement is the declaration of the SQLCA (SQL Communications Area), which you can use for error handling in the context of database statements. As mentioned above, you should issue the statement in your main program and in each subprogram that contains Embedded SQL statements. The declaration for the SQLCA is:
     character*8    sqlcai
     integer*4      sqlcab 
     integer*4      sqlcod 
     integer*2      sqltxl 
     character*70   sqltxt 
     character*8    sqlerp 
     integer*4      sqlerr(6) 
     character*1    sqlwrn(0:7) 
     character*8    sqlext
 common /sqlca/ sqlcai, sqlcab, sqlcod, sqltxl, sqltxt, 
1           sqlerp, sqlerr, sqlwrn, sqlext
This definition varies from the more standard definition of some other implementations. Also, because the names of the SQLCA fields conform to the names given in other implementations of Embedded SQL/Fortran, they are different from those mentioned in the SQL Reference Guide. The names of the fields most commonly used are sqlcod and sqlerr. These fields are equivalent to the fields sqlcode and sqlerrd described in the SQL Reference Guide. For a full description of all the SQLCA fields, see that guide.
The SQLCA is initialized at load time. The sqlcai and sqlcab fields are initialized to the string "SQLCA" and the constant 136, respectively.
The preprocessor is not aware of the SQLCA declaration. Therefore, you cannot use SQLCA fields in an Embedded SQL statement. For example, the following statement, attempting to insert the error code sqlcod into a table, generates an error:
C This statement is illegal
         exec sql insert into employee (eno) 
      1 values (:sqlcod)
All modules (written in Fortran or other Embedded SQL languages) share the same SQLCA.
Last modified date: 11/09/2022