5. Working with Embedded SQL : Dynamic Programming : SQLDA : Structure of the SQLDA
 
Share this page                  
Structure of the SQLDA
Typically, storage for the SQLDA structure is allocated at runtime. If a program allows several dynamically defined cursors to be opened at one time, the program can allocate several SQLDA structures, one for each SELECT statement, and assign each structure a different name.
Each host language has different considerations for the SQLDA structure. Before writing a program that uses the SQLDA, see the Embedded SQL Companion Guide.
The layout of the SQLDA is shown in the following table:
SQLDA Structure
Description
sqldaid
8-byte character array assigned the blank-padded value SQLDA.
sqldabc
4-byte integer assigned the size of the SQLDA.
sqln
2-byte integer indicating the number of allocated sqlvar elements. This value must be set by the program before describing a statement, form, or table field. The value must be greater than or equal to zero.
sqld
2-byte integer indicating the number of result columns associated with the DESCRIBE statement. This number specifies how many of the allocated sqlvar elements were used to describe the statement. If sqld is greater than sqln, the program must reallocate the SQLDA to provide more storage buffers and reissue the DESCRIBE statement.
To use the SQLDA to place values in a table, the program must set sqld to the correct number before the SQLDA is used in a statement.
When describing a dynamic SQL statement, if the value in sqld is zero, the described statement is not a SELECT statement.
sqlvar
A sqln-size array composed of the following elements:
sqltype--2-byte integer indicating the length data type of the column, variable, or field.
sqllen--2-byte integer indicating the length of the column, variable, or field.
sqldata--Pointer.
sqlind--Pointer to indicator variable associated with the host language variable. Your program must also allocate the memory to which this variable points.
sqlname--The result column name (when a SELECT statement is described).