A PL/I program that contains SQL statements must include an SQL communications area (SQLCA) As shown in Figure 1 part of an SQLCA consists of an SQLCODE variable and an SQLSTATE variable.
The SQLCA should be included by using the SQL INCLUDE statement:
exec sql include sqlca;
The SQLCA must not be defined within an SQL declare section. The scope of the SQLCODE and SQLSTATE declaration must include the scope of all SQL statements in the program.
Dcl
1 Sqlca,
2 sqlcaid char(8), /* Eyecatcher = 'SQLCA '*/
2 sqlcabc fixed binary(31), /* SQLCA size in bytes = 136 */
2 sqlcode fixed binary(31), /* SQL return code */
2 sqlerrm char(70) var, /* Error message tokens */
2 sqlerrp char(8), /* Diagnostic information */
2 sqlerrd(6) fixed binary(31), /* Diagnostic information */
2 sqlwarn, /* Warning flags */
3 sqlwarn0 char(1),
3 sqlwarn1 char(1),
3 sqlwarn2 char(1),
3 sqlwarn3 char(1),
3 sqlwarn4 char(1),
3 sqlwarn5 char(1),
3 sqlwarn6 char(1),
3 sqlwarn7 char(1),
2 sqlext,
3 sqlwarn8 char(1),
3 sqlwarn9 char(1),
3 sqlwarna char(1),
3 sqlstate char(5); /* State corresponding to SQLCODE */