An SQLDA structure may be required for dynamically executed SQL statements. There are two ways to declare the SQLDA structure:
EXEC SQL INCLUDE SQLDA
The preprocessor replaces this with a declaration of the SQLDA structure.
Figure 104. SQLDA Structure (in Assembler)
SQLDA DSECT SQLDAID DS CL8 SQLDABC DS F SQLN DS H SQLD DS H SQLVAR DS 0F SQLVARN DSECT SQLTYPE DS H SQLLEN DS 0H SQLPRSCN DS CL1 SQLSCALE DS CL1 SQLDATA DS A SQLIND DS A SQLNAME DS H,CL30 &SYSECT CSECT |
The SQLDA structure must not be declared within an SQL declare section. When you specify INCLUDE SQLDA, the assembler preprocessor generates a CSECT statement at the end of the SQLDA. This CSECT is generated with the name of the CSECT currently active in your program.
You must not specify a constant string on a PREPARE or EXECUTE IMMEDIATE statement. You can only specify a host variable defined as a variable-length character string:
EXEC SQL PREPARE S1 FROM :STRING1 EXEC SQL EXECUTE IMMEDIATE :STRING1 . . EXEC SQL BEGIN DECLARE SECTION STRING1 DS H,CLxxxxx (xxxxx <= 8192) EXEC SQL END DECLARE SECTION
The halfword of STRING1 must contain the length of the string, and the character portion must contain the string itself when the PREPARE or EXECUTE IMMEDIATE statement is executed.
See Appendix B of the DB2 Server for VSE & VM SQL Reference manual for more information on the individual fields within SQLDA.