Contents of the SQLCA
One of the results of issuing the include sqlca statement is the declaration of the SQLCA (SQL Communications Area) structure, which you can use for error handling in the context of database statements. You must only issue the statement once, because it generates a record declaration. The record declaration for the SQLCA is:
Windows:
01 SQLCA.
05 SQLCAID PIC X(8).
05 SQLCABC PIC S9(9) USAGE COMP-5.
05 SQLCODE PIC S9(9) USAGE COMP-5.
05 SQLERRM.
10 SQLERRML PIC S9(4) USAGE COMP-5.
10 SQLERRMC PIC X(70).
05 SQLERRP PIC X(8).
05 SQLERRD PIC S9(9) USAGE COMP-5
OCCURS 6 TIMES..
05 SQLWARN.
10 SQLWARN0 PIC X(1).
10 SQLWARN1 PIC X(1).
10 SQLWARN2 PIC X(1).
10 SQLWARN3 PIC X(1).
10 SQLWARN4 PIC X(1).
10 SQLWARN5 PIC X(1).
10 SQLWARN6 PIC X(1).
10 SQLWARN7 PIC X(1).
05 SQLEXT PIC X(8).
UNIX:
01 SQLCA.
05 SQLCAID PIC X(8).
05 SQLCABC PIC S9(9) USAGE COMP-5.
05 SQLCODE PIC S9(9) USAGE COMP-5.
05 SQLERRM.
10 SQLERRML PIC S9(4) USAGE COMP-5.
10 SQLERRMC PIC X(70).
05 SQLERRP PIC X(8).
05 SQLERRD PIC S9(9) USAGE COMP-5
OCCURS 6 TIMES..
05 SQLWARN.
10 SQLWARN0 PIC X(1).
10 SQLWARN1 PIC X(1).
10 SQLWARN2 PIC X(1).
10 SQLWARN3 PIC X(1).
10 SQLWARN4 PIC X(1).
10 SQLWARN5 PIC X(1).
10 SQLWARN6 PIC X(1).
10 SQLWARN7 PIC X(1).
05 SQLEXT PIC X(8).
VMS:
01 SQLCA.
05 SQLCAID PIC X(8).
05 SQLCABC PIC S9(9) USAGE COMP.
05 SQLCODE PIC S9(9) USAGE COMP.
05 SQLERRM.
49 SQLERRML PIC S9(4) USAGE COMP.
49 SQLERRMC PIC X(70).
05 SQLERRP PIC X(8).
05 SQLERRD PIC S9(9) USAGE COMP
OCCURS 6 TIMES.
05 SQLWARN.
10 SQLWARN0 PIC X(1).
10 SQLWARN1 PIC X(1).
10 SQLWARN2 PIC X(1).
10 SQLWARN3 PIC X(1).
10 SQLWARN4 PIC X(1).
10 SQLWARN5 PIC X(1).
10 SQLWARN6 PIC X(1).
10 SQLWARN7 PIC X(1).
05 SQLEXT PIC X(8).
For a full description of the SQLCA data items, see the SQL Reference Guide.
The SQLCA is initialized at load‑time. The fields SQLCAID and SQLCABC are initialized to the string SQLCA and the constant 136, respectively.
Note that the preprocessor is not aware of the record declaration. Therefore, you cannot use the record items in an embedded SQL statement. For example, the following statement, which attempts to insert the string SQLCA into a table, generates an error:
* This statement is illegal
EXEC SQL INSERT INTO employee (ename)
VALUES (:SQLCAID);
Windows and UNIX:
The SQLCA is local to the program that issued the
include sqlca statement.
VMS:
All modules from different languages that are linked together share the same SQLCA.