The format for an SQL INCLUDE directive is similar to other SQL statements:
EXEC SQL INCLUDE member-name ;
Note: INCLUDEs in the C language are basically the same as in PL/I, but see the exceptions for C noted in INCLUDEs in C.
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 notes the error and does not read its contents. If a PL/I INCLUDE is embedded in the SQL INCLUDE, the Preprocessor ignores it.
Except for SQLDA, member names that begin with the letters SQL are not included because these are assumed to be control block names. The EXEC SQL INCLUDE statement is, however, commented. When INCLUDE SQLDA is specified, the Preprocessor for PL/I 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. If the Preprocessor is able to open the INCLUDE, the records contained in the INCLUDE are inserted in the source after the semicolon of the SQL INCLUDE. These records are processed as if they were source except in the case of an INCLUDE within an INCLUDE, as mentioned above.
In the modified source the SQL INCLUDE directive is commented.
The following examples illustrate the inclusion of host declarations from INCLUDEs. In one case the SQL declaration section statements are in the INCLUDE itself. The other INCLUDE contains only PL/I declarations.
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 the letter P or any letter designated by the ITYP= Preprocessor option. The DLBL name must be INCLUDE.
EXEC SQL INCLUDE SQLCA causes the SQLCA to be generated at that point in the source rather than with other SQL request blocks.
PL/I Example 1
Following is the source:
/*---------------------------------------------
This INCLUDE contains the statements for
an SQL declare section.
*--------------------------------------------*/
EXEC SQL INCLUDE PL1INCT1 ;
Following is the report for the source after the INCLUDE is read. The INCLUDE source is denoted by a plus sign after the sequence number. The sequence number is the record number for the respective file (source or INCLUDE).
Report for Source after INCLUDE is Read (Example 1— PL/I)
34
35 /*---------------------------------------------
36 This INCLUDE contains the statements for
37 an SQL declare section.
38 *--------------------------------------------*/
39 EXEC SQL INCLUDE PL1INCT1 ;
1+ /*---------------------------------------------------------------------
2+ test include with storage only
3+ *--------------------------------------------------------------------*/
4+
5+ EXEC SQL BEGIN DECLARE SECTION ;
6+ DECLARE CHSEQ CHAR(2) INIT('02'); /* host */
7+ DECLARE HSEQ CHAR(2) INIT(' '); /* host */
8+ DECLARE HNAME CHAR(20) INIT(' '); /* host */
9+ DECLARE HSSAN CHAR(11) INIT(' '); /* host */
10+ DECLARE HCITY CHAR(10) INIT(' '); /* host */
11+ DECLARE HZIP PIC'9999T'; /* host */
12+ DECLARE (ISEQ, INAME, ISSAN, ICITY, IZIP )
13+ FIXED BINARY(15) INIT(0); /* indicator */
14+ EXEC SQL END DECLARE SECTION ;
15+ /* end include */
40
Following is the report for the modified source that is used as input to the compiler:
Report for the Modified Source (Example 1— PL/I)
34
35 /*---------------------------------------------
36 This INCLUDE contains the statements for
37 an SQL declare section.
38 *--------------------------------------------*/
/* commented by CA-DATACOM/DB Preprocessor *
39 EXEC SQL INCLUDE PL1INCT1 ;
* commented by CA-DATACOM/DB Preprocessor */
1+ /*---------------------------------------------------------------------
2+ test include with storage only
3+ *--------------------------------------------------------------------*/
4+
/* commented by CA-DATACOM/DB Preprocessor *
5+ EXEC SQL BEGIN DECLARE SECTION ;
* commented by CA-DATACOM/DB Preprocessor */
6+ DECLARE CHSEQ CHAR(2) INIT('02'); /* host */
7+ DECLARE HSEQ CHAR(2) INIT(' '); /* host */
8+ DECLARE HNAME CHAR(20) INIT(' '); /* host */
9+ DECLARE HSSAN CHAR(11) INIT(' '); /* host */
10+ DECLARE HCITY CHAR(10) INIT(' '); /* host */
11+ DECLARE HZIP PIC'9999T'; /* host */
12+ DECLARE (ISEQ, INAME, ISSAN, ICITY, IZIP )
13+ FIXED BINARY(15) INIT(0); /* indicator */
/* commented by CA-DATACOM/DB Preprocessor *
14+ EXEC SQL END DECLARE SECTION ;
* commented by CA-DATACOM/DB Preprocessor */
15+ /* end include */
40
PL/I Example 2
Following is the source:
/*---------------------------------------------
This INCLUDE contains only declarations.
*--------------------------------------------*/
EXEC SQL BEGIN DECLARE SECTION ;
EXEC SQL INCLUDE PL1INCT2 ;
EXEC SQL END DECLARE SECTION ;
Following is the report for the source after the INCLUDE is read:
Report for Source after INCLUDE is Read (Example 2— PL/I)
41 /*---------------------------------------------
42 This include contains only declarations.
43 *--------------------------------------------*/
44 EXEC SQL BEGIN DECLARE SECTION ;
45 EXEC SQL INCLUDE PL1INCT2 ;
1+ /*---------------------------------------------------------------------
2+ test include with storage only within declare section
3+ *--------------------------------------------------------------------*/
4+
5+ DECLARE CHSEQ CHAR(2) INIT('02'); /* host */
6+ DECLARE HSEQ CHAR(2) INIT(' '); /* host */
7+ DECLARE HNAME CHAR(20) INIT(' '); /* host */
8+ DECLARE HSSAN CHAR(11) INIT(' '); /* host */
9+ DECLARE HCITY CHAR(10) INIT(' '); /* host */
10+ DECLARE HZIP PIC'9999T'; /* host */
11+ DECLARE (ISEQ, INAME, ISSAN, ICITY, IZIP )
12+ FIXED BINARY(15) INIT(0); /* indicator */
13+ /* end include */
46 EXEC SQL END DECLARE SECTION ;
47
Following is the report for the modified source that is used as input to the compiler:
Report for the Modified Source (Example 2— PL/I)
41 /*---------------------------------------------
42 This INCLUDE contains only declarations.
43 *--------------------------------------------*/
/* commented by CA-DATACOM/DB Preprocessor *
44 EXEC SQL BEGIN DECLARE SECTION ;
45 EXEC SQL INCLUDE PL1INCT2 ;
* commented by CA-DATACOM/DB Preprocessor */
1+ /*---------------------------------------------------------------------
2+ test include with storage only within declare section
3+ *--------------------------------------------------------------------*/
4+
5+ DECLARE CHSEQ CHAR(2) INIT('02'); /* host */
6+ DECLARE HSEQ CHAR(2) INIT(' '); /* host */
7+ DECLARE HNAME CHAR(20) INIT(' '); /* host */
8+ DECLARE HSSAN CHAR(11) INIT(' '); /* host */
9+ DECLARE HCITY CHAR(10) INIT(' '); /* host */
10+ DECLARE HZIP PIC'9999T'; /* host */
11+ DECLARE (ISEQ, INAME, ISSAN, ICITY, IZIP )
12+ FIXED BINARY(15) INIT(0); /* indicator */
13+ /* end include */
/* commented by CA-DATACOM/DB Preprocessor *
46 EXEC SQL END DECLARE SECTION ;
* commented by CA-DATACOM/DB Preprocessor */
47
PL/I Example 3
Following is an example of the source:
/*---------------------------------------------
This INCLUDE contains an SQL open statement.
*--------------------------------------------*/
EXEC SQL INCLUDE PL1INCT6 ;
Following is the report for the source after the INCLUDE is read:
Report for Source after INCLUDE is Read (Example 3— PL/I)
87 /*--------------------------------------------- 88 This include contains an SQL open statement. 89 *--------------------------------------------*/ 90 EXEC SQL INCLUDE PL1INCT6 ; 1+ EXEC SQL OPEN C1 2+ ; 91
Following is the report for the modified source that is used as input to the compiler:
Report for the Modified Source (Example 3— PL/I)
87 /*---------------------------------------------
88 This INCLUDE contains an SQL open statement.
89 *--------------------------------------------*/
/* commented by CA-DATACOM/DB Preprocessor *
90 EXEC SQL INCLUDE PL1INCT6 ;
1+ EXEC SQL OPEN C1
2+ ;
* commented by CA-DATACOM/DB Preprocessor */
/* start of CA-DATACOM/DB Preprocessor generation */
IF XYZK6_DBPRIME = XYZK6_DBPRIME_YES
THEN CALL XYZK6_DBINIT;
CALL DBSQLE( SQLCA, SQLWA0);
/* end of CA-DATACOM/DB Preprocessor generation */
91
|
Copyright © 2014 CA.
All rights reserved.
|
|