INCLUDE statement

The INCLUDE statement inserts declarations into a source program.

Invocation

This statement can only be embedded in an application program. It is not an executable statement.

Authorization

None required.

Syntax

Read syntax diagramSkip visual syntax diagramINCLUDESQLCASQLDAname

Description

SQLCA
Indicates the description of an SQL communication area (SQLCA) is to be included.
SQLDA
Indicates the description of an SQL descriptor area (SQLDA) is to be included.
name
Identifies an external file containing text that is to be included in the source program being precompiled. It can be an SQL identifier without a file name extension or a literal enclosed by single quotation marks (' '). An SQL identifier assumes the filename extension of the source file being precompiled. If a file name extension is not provided by a literal enclosed by quotation marks, none is assumed.

Notes

  • When a program is precompiled, the INCLUDE statement is replaced by source statements. Thus, the INCLUDE statement should be specified at a point in the program such that the resulting source statements are acceptable to the compiler.
  • The external source file must be written in the host language specified by name. If it is greater than 18 bytes or contains characters that are not allowed in an SQL identifier, it must be enclosed by single quotation marks. INCLUDE name statements may be nested though not cyclical (for example, if A and B are modules and A contains an INCLUDE name statement, then it is not valid for A to call B and then B to call A).
  • When the LANGLEVEL precompile option is specified with the SQL92E value, INCLUDE SQLCA should not be specified. SQLSTATE and SQLCODE variables may be defined within the host variable declare section.

Example

Include an SQLCA in a C program.
   EXEC SQL INCLUDE SQLCA;

   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;