Preparing the Output XSQLDA to Read Data from an Array
From InterBase
Go Up to Reading Data from an Array
Most queries return one or more rows of data, referred to as a select-list. An output XSQLDA
must be created to store the column data for each row that is fetched. For an array column, the column data is an internal array identifier (array ID) that is needed to access the actual data. To prepare the XSQLDA
, follow these steps:
- Declare a variable to hold the
XSQLDA
. For example, the following declaration creates anXSQLDA
called out_sqlda
:XSQLDA *out_sqlda;
- Allocate memory for the
XSQLDA
using theXSQLDA_LENGTH
macro. TheXSQLDA
must contain oneXSQLVAR
substructure for each column to be fetched. The following statement allocates storage for an outputXSQLDA
(out_sqlda
) with twoXSQLVAR
substructures:out_sqlda = (XSQLDA *)malloc(XSQLDA_LENGTH(2));
- Set the
version
field of theXSQLDA
toSQLDA_CURRENT_VERSION
, and set thesqln
field of theXSQLDA
to indicate the number ofXSQLVAR
substructures allocated:out_sqlda->version = SQLDA_CURRENT_VERSION; out_sqlda->sqln = 2;