The INCLUDE statement inserts declarations or statements into a source program.
This statement can only be embedded in an application program. It is not an executable statement. It must not be specified in Java™ or REXX.
The authorization ID of the statement must have the system authorities *OBJOPR and *READ on the file that contains the member.
>>-INCLUDE--+-SQLCA-+------------------------------------------><
+-SQLDA-+
'-name--'
An SQLCA can be specified for C, COBOL, and PL/I. If the SQLCA is not specified, the variable SQLCODE or SQLSTATE must appear in the program. For more information, see SQL return codes.
The SQLCA should not be specified for RPG programs. In an RPG program, the precompiler automatically includes the SQLCA.
For a description of the SQLCA, see Appendix C. SQLCA (SQL communication area).
For a description of the SQLDA, see Appendix D. SQLDA (SQL descriptor area).
The member can contain any host language statements and any SQL statements other than an INCLUDE statement. In COBOL, INCLUDE member-name must not be specified in other than the DATA DIVISION or PROCEDURE DIVISION.
When your program is precompiled, the INCLUDE statement is replaced by source statements.
The INCLUDE statement must be specified at a point in your program where the resulting source statements are acceptable to the compiler.
CCSID considerations: If the CCSID of the source file specified on the SRCFILE parameter is different from the CCSID of the source file specified on the INCFILE parameter, the source from the INCLUDE statement is converted to the CCSID of the source file.
Include an SQL descriptor area in a C program.
EXEC SQL INCLUDE SQLDA; EXEC SQL DECLARE C1 CURSOR FOR SELECT DEPTNO, DEPTNAME, MGRNO FROM TDEPT WHERE ADMRDEPT = 'A00'; EXEC SQL OPEN C1; while (SQLCODE==0) { EXEC SQL FETCH C1 INTO :dnum, :dname, mnum; /* Print results */ } EXEC SQL CLOSE C1;