DB2 Server for VSE & VM: Application Programming


Using Dynamic SQL Statements in Assembler Language

An SQLDA structure may be required for dynamically executed SQL statements. There are two ways to declare the SQLDA structure:

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.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]