Previous Topic: Host Variable Declarations for AssemblerNext Topic: Coding Embedded SQL in C


Rules for SQL INCLUDEs in Assembler

The format for an SQL INCLUDE directive is similar to other SQL statements:

 EXEC SQL INCLUDE member-name

Each SQL INCLUDE may specify only one member name contained in the INCLUDE data set. You may, however, code more than one SQL INCLUDE.

INCLUDEs cannot include other INCLUDEs. If an SQL INCLUDE is embedded in an SQL INCLUDE, the Preprocessor for Assembler notes the error and does not read its contents. Likewise, macros are not expanded nor are any other copy types processed.

With the exception of SQLCA and SQLDA, member names that begin with the letters SQL are not included because these are assumed to be control block names. EXEC SQL INCLUDE SQLCA causes separate generation of the SQLCA DSECT. When INCLUDE SQLDA is specified, the Preprocessor for Assembler includes the description of a SQL Descriptor Area (SQLDA) for use by dynamic SQL statements.

SQL INCLUDEs are processed in a special manner by the Preprocessor for Assembler. If the Preprocessor for Assembler is able to open the INCLUDE, the records contained in the INCLUDE are inserted in the source after the SQL INCLUDE. These records are processed as if they were source.

In the modified source the SQL INCLUDE directive is commented.

The following examples illustrate the inclusion of host definitions from INCLUDEs. In one case the SQL declaration section statements are in the INCLUDE itself.

For z/OS, the name in the EXEC SQL INCLUDE is the name of the member in the partition data set of the INCLUDE DD.

For z/VSE, the name in the EXEC SQL INCLUDE is part of the member name in the z/VSE library. The other part, the file or book type, is designated by the ITYP= Preprocessor for Assembler option. The DLBL name must be INCLUDE.

Assembler Example 1

Following is an example of the source:

 EXEC SQL INCLUDE ASMINCT3

Following is the report for the source after the INCLUDE is read:

 52        EXEC SQL INCLUDE ASMINCT3
  1+*--------------------------------------------
  2+*  example of including an SQL statement
  3+*--------------------------------------------
  4+*
  5+  EXEC SQL DECLARE                                                              X
  6+              C1 CURSOR FOR                                                     X
  7+          SELECT SEQ,                                                           X
  8+                 NAME                                                           X
  9+                    FROM GACTBLV
 10+*
 11+*------- end include --------*
 53 *

Following is the report for the modified source:

Report for the Modified Source (Example 1— Assembler)

 52 *      EXEC SQL INCLUDE ASMINCT3
  1+*--------------------------------------------
  2+*  example of including an SQL statement
  3+*--------------------------------------------
  4+*
  5+* EXEC SQL DECLARE
  6+*             C1 CURSOR FOR
  7+*         SELECT SEQ,
  8+*                NAME
  9+*                   FROM GACTBLV
 10+*
 11+*------- end include --------*
 53 *

Assembler Example 2

Following is an example of the source:

 EXEC SQL INCLUDE ASMINCT4

Following is the report for the source after the INCLUDE is read:

Report for Source after INCLUDE is Read (Example 2— Assembler)

 53 *
 54        EXEC SQL INCLUDE ASMINCT4
  1+  EXEC SQL OPEN C1
 55 *

Following is the report for the modified source:

Report for the Modified Source (Example 2— Assembler)

 53 *
 54 *      EXEC SQL INCLUDE ASMINCT4
  1+* EXEC SQL OPEN C1
    *------ start of CA-DATACOM/DB generation ------
             BAL   14,SQLINIT
             LA    1,SQL0
             ST    1,SQLPWA
             LA    1,SQLPARMS
             L     15,SQLVSQLE
             BALR  14,15
             TM    SQLCODE,X'80'
             BO    DUMPNOW
    *------ end of CA-DATACOM/DB generation --------
 55 *