Progress
Embedded SQL-92
Guide and Reference
Allocating an SQLDA
Allocate an SQLDA structure by calling the sqld_alloc( ) function. Do not use a static declaration. You must also declare a pointer to the SQLDA.
EXAMPLESThe first example shows a valid declaration:
The next example shows an invalid declaration of an SQLDA structure:
The sqld_alloc function accepts a size argument that specifies the maximum number of variables for which the structure should be allocated. The syntax for the sqld_alloc function is:
The sqld_alloc function allocates an SQLDA from heap storage. The numVars variable specifies the maximum number of variables for which the SQLDA is allocated. varNameLen is the maximum number of characters to hold the names of the columns in the result table corresponding to the SQL statement. If your application does not need column names, set varNameLen to zero ( 0 ).
EXAMPLEThe following code fragment illustrates how to allocate an SQLDA and verify that the allocation succeeded:
NOTE: The sqld_alloc function does not allocate memory for data buffers and indicator variable buffers. Allocation for data buffers and indicator variables must be performed by the application separately, and pointers to these must be set in the SQLDA.Setting the SQLDA Types and Lengths
You use an SQLDA for both input host variables and output host variables. These variables are values that are not known beforehand. When you use an SQLDA to supply values to input host variables referenced in a dynamic non-SELECT statement, be sure to set the type and length of the values in the SQLDA. The SQLDA components SQLD_LENGTHS and SQLD_TYPES must be set correctly. For dynamic SELECT statements, issue a DESCRIBE statement to determine the types and lengths of the values the SELECT statement returns. When using an input SQLDA, you may also need to set the SQLD_SCALE and SQLD_PRECISION values for certain columns (e.g. set scale when the data type is NUMERIC). Also remember to add space in the SQLD_LENGTHS for the null(0) terminator byte when the data is CHARACTER or VARCHAR. If you do not do a DESCRIBE, you will need to set SQLD_NVARS yourself.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |