Creating the Input XSQLDA
From InterBase
Go Up to Method 2: Non-query Statements With Parameters
Placeholder parameters are replaced with actual data before a prepared SQL statement string is executed. Because those parameters are unknown when the statement string is created, an input XSQLDA must be created to supply parameter values at execute time. To prepare the XSQLDA, follow these steps:
- Declare a variable to hold the
XSQLDAneeded to process parameters. For example, the following declaration creates anXSQLDAcalledin_sqlda:XSQLDA *in_sqlda;
- Optionally declare a variable for accessing the
XSQLVARstructure of theXSQLDA:Declaring a pointer to theXSQLVAR *var;
XSQLVARstructure is not necessary, but can simplify referencing the structure in subsequent statements. - Allocate memory for the
XSQLDAusing theXSQLDA_LENGTHmacro. The following statement allocates storage forin_sqlda:In this statement space for tenin_sqlda = (XSQLDA *)malloc(XSQLDA_LENGTH(10));
XSQLVARstructures is allocated, allowing theXSQLDAto accommodate up to ten parameters. - Set the
versionfield of theXSQLDAtoSQLDA_CURRENT_VERSION, and set thesqlnfield to indicate the number ofXSQLVARstructures allocated:in_sqlda->version = SQLDA_CURRENT_VERSION; in_sqlda->sqln = 10;