INCLUDE

The INCLUDE statement inserts application code, including declarations and statements, into a source program.

Invocation

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.

Authorization

The authorization ID of the statement must have the system authorities *OBJOPR and *READ on the file that contains the member.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-INCLUDE--+-SQLCA----+---------------------------------------><
            +-SQLDA----+   
            +-name-----+   
            '-'string'-'   

Description

SQLCA
Indicates the description of an SQL communication area (SQLCA) is to be included. Include SQLCA must not be specified if the program includes a stand-alone SQLCODE or a stand-alone SQLSTATE. An SQLCA can be specified for C, C++, COBOL, and PL/I. If the SQLCA is not specified, the variable SQLCODE or SQLSTATE must appear in the program.

INCLUDE SQLCA must not be specified more than once in the same program. For more information, see SQL diagnostic information.

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 SQLCA (SQL communication area).

SQLDA
Specifies the description of an SQL descriptor area (SQLDA) is to be included. INCLUDE SQLDA can be specified in C, C++, COBOL, PL/I, and ILE RPG.

For a description of the SQLDA, see SQLDA (SQL descriptor area).

name
Identifies a member or source stream file to be included in the source program.

If precompiling using the SRCFILE parameter, it identifies a member to be included from the file specified on the INCFILE parameter of the CRTSQLxxx command.

If precompiling using the SRCSTMF parameter, it identifies a file to be included using the path from the INCDIR parameter of the CRTSQLxxx command. No suffix will be appended to the name.

The source 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.

'string'
Identifies a file to be included using the path from the INCDIR parameter of the CRTSQLxxx command. The string will be handled as a normal SQL string literal; the source stream file rules for escaping characters will not be followed. No suffix will be appended to the string.

The source can contain any host language statements and any SQL statements other than an INCLUDE statement.

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.

Notes

CCSID considerations: If the CCSID of the file specified on the SRCFILE or SRCSTMF parameter is different from the CCSID of the source for the INCLUDE statement, the INCLUDE source is converted to the CCSID of the source file.

Example

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;