The SQLDA data structure contains descriptive information about each input parameter or output column. The structure contains the column name, the datatype, the length, and a pointer to the actual data buffer for each input or output parameter.
For output data that uses the SQLDA data structure, you can use the DESCRIBE statement (or the PREPARE statement with the INTO option) to enter the column name, the datatype, and other data into the appropriate fields of the SQLDA data structure.
Before using the SQLDA data structure in a PREPARE INTO or DESCRIBE statement, your application must set the size of the SQLDA data structure in bytes and the maximum number of entries. These numbers are reflected in the sqldabc and sqln fields, respectively.
Before performing a FETCH statement, the application must insert into the sqldata field the address of each program variable that will receive the data from the corresponding column. (The sqldata field is part of sqlvar within the SQLDA data structure.) If indicator variables are used, sqlind must also be set to the corresponding address. The datatype field (sqltype) and length field (sqllen) are filled with information in the SQL Server column from a PREPARE INTO or a DESCRIBE statement. The value in the datatype and length fields can be overridden by the application before a FETCH statement is executed. The sqltype code and the sqld address that are assigned must be one of the valid datatypes that are listed in the "Valid Values for sqltype" section, later in this chapter.
Before the DESCRIBE or PREPARE statement is issued, the value of sqln must be set higher than the anticipated number of output columns. If the number of columns is unknown, you can set sqln to 0 and then issue a DESCRIBE statement. No column detail information is moved into the SQLDA data structure, but the number of columns in the results set is inserted into sqld.
To use the SQLDA data structure for input data, your application must supply data for the fields of the entire SQLDA data structure, including the sqln, sqld, sqldabc, sqltype, sqllen, and sqldata fields for each variable. If the sqltype field has an odd code number (value), the address of the indicator variable must also be supplied.