The FORTRAN preprocessor lets you use a descriptor area, the SQLDA, to execute dynamically defined SQL statements. (See Chapter 7, Using Dynamic Statements for information on dynamic SQL statements and the SQLDA.) However, the FORTRAN preprocessor will not replace the statement EXEC SQL INCLUDE SQLDA with a declaration of the SQLDA structure, as is done with the SQLCA. Instead EXEC SQL INCLUDE SQLDA would just include the secondary input file SQLDA, as described in the section Using the INCLUDE Statement.
Before you can use the descriptor area you must properly allocate and initialize it, and you must manage all its address variables. The following example shows how you could define the descriptor area in FORTRAN for three fields:
. CHARACTER*8 DAID INTEGER*4 DABC INTEGER*2 DASQLN, * DAD, * DATYPE_1, DATYPE_2, DATYPE_3, * DALEN_1, DALEN_2, DALEN_3, * DANLN_1, DANLN_2, DANLN_3 INTEGER*4 DADATA_1, DADATA_2, DADATA_3, * DAIND_1, DAIND_2, DAIND_3 CHARACTER*30 DANAME_1, DANAME_2, DANAME_3 COMMON /DASQL/ DAID, DABC, DAN, DAD, * DATYPE_1, DALEN_1, DADATA_1, DAIND_1, DANLN_1, DANAME_1, * DATYPE_2, DALEN_2, DADATA_2, DAIND_2, DANLN_2, DANAME_2, * DATYPE_3, DALEN_3, DADATA_3, DAIND_3, DANLN_3, DANAME_3 |
The descriptor area must not be declared within the SQL declare section.
The following pseudocode illustrates the use of a descriptor area, adequate for three fields:
- allocate storage for a Descriptor Area of at least size = 3 - set DAN = 3 (number of fields) - set DAD = 3 - set the rest of the values and pointers in the Descriptor Area EXEC SQL EXECUTE S1 USING DESCRIPTOR dasql |