Defining SQL descriptor areas (SQLDA) in assembler
If your program includes certain SQL statements, you must define at least one SQL descriptor area (SQLDA). Depending on the context in which it is used, the SQLDA stores information about prepared SQL statements or host variables. This information can then be read by either the application program or Db2.
Procedure
To define SQL descriptor areas:
Code the SQLDA directly in the program, or use the following SQL INCLUDE statement to request a standard SQLDA declaration:
EXEC SQL INCLUDE SQLDA
Restriction: You must place SQLDA declarations before the first SQL statement that references the data descriptor, unless you use the TWOPASS SQL processing option.
Example
You can use host-variable arrays for certain multi-row operations in other host languages, such C, C++, COBOL, and PL/I. but the Db2 precompiler does not recognize declarations of host-variable arrays for assembler. However, you can SQLDA declarations to achieve similar results in assembler programs, as shown in the following examples:
- Assembler support for multiple-row FETCH is limited to the FETCH statement with the INTO DESCRIPTOR clause. For example:
EXEC SQL FETCH NEXT ROWSET FROM C1 FOR 10 ROWS X INTO DESCRIPTOR :SQLDA
- Assembler support for multiple-row INSERT is limited to the following cases:
- Static multiple-row INSERT statement with scalar values (scalar host variables or scalar expressions) in the VALUES clause. For example:
EXEC SQL INSERT INTO T1 VALUES (1, CURRENT DATE, 'TEST') X FOR 10 ROWS
- Dynamic multiple-row INSERT executed with the USING DESCRIPTOR clause on the EXECUTE statement. For example:
ATR DS CL20 ATTRIBUTES FOR PREPARE S1 DS H,CL30 VARCHAR STATEMENT STRING MVC ATR(20),=C'FOR MULTIPLE ROWS ' MVC S1(2),=H'25' MVC S1+2(30),=C'INSERT INTO T1 VALUES (?) ' EXEC SQL PREPARE STMT ATTRIBUTES :ATR FROM :S1 EXEC SQL EXECUTE STMT USING DESCRIPTOR :SQLDA FOR 10 ROWS where the descriptor is set up correctly in advance according to the specifications for dynamic execution of a multiple-row INSERT statement with a descriptor
- Assembler does not support multiple-row MERGE. You cannot specify MERGE statements that reference host-variable arrays.
- Static multiple-row INSERT statement with scalar values (scalar host variables or scalar expressions) in the VALUES clause. For example: