Entering content frame

 Using the Descriptor 

Use

If, during the programming phase, you do not know the table columns addressed by a dynamic SQL statement with parameters, and, therefore, the required parameters, then use a descriptor.

At runtime, the application program determines the number, data types, and lengths of the table columns addressed by an SQL statement, and saves this information in the structure sqlda (SQL Descriptor Area, descriptor for short).

You can then use this information to assign the appropriate program variables to the parameters in the SQL statement.

See also: Example for Using a Descriptor

Prerequisite

You have used the PREPARE statement to prepare the dynamic SQL statement.

Procedure

       1.      Initialize the descriptor with the DESCRIBE statement.

       2.      Use the information in the descriptor to assign appropriate program variables to the parameters in the dynamic SQL statement. To do this, enter the addresses of these program variables in the descriptor structure as well.

Make sure that the program variables contain valid values at runtime.

       3.      Use the EXECUTE statement or the OPEN CURSOR statement with the USING clause.

If you use the SQL mode INTERNAL, the C/C++ precompiler defines an initial descriptor called sqlda automatically. In other modes, and if you want to use other descriptors, declare them as variables with the data type sqlda. This data type is defined in the header file cpc.h.

 

Leaving content frame