![]() | ![]() |
Home |
|
|
|
| Chapter 2: The Embedded SQL Interface |
|
| Library functions |
|
| SQLDA management functions |
The following functions are used to manage SQL Descriptor Areas (SQLDAs).
For a detailed description of the SQLDA, see The SQL descriptor area (SQLDA) .
struct sqlda *alloc_sqlda_noind( unsigned numvar );
Allocates a SQLDA with descriptors for numvar variables. The sqln field of the SQLDA is initialized to numvar . Space is not allocated for indicator variables; the indicator pointers are set to the null pointer. A null pointer is returned if memory cannot be allocated.
struct sqlda *alloc_sqlda( unsigned numvar );
Allocates a SQLDA with descriptors for numvar variables. The sqln field of the SQLDA is initialized to numvar . Space is allocated for the indicator variables, the indicator pointers are set to point to this space, and the indicator value is initialized to zero. A null pointer is returned if memory cannot be allocated.
struct sqlda *fill_sqlda( struct sqlda *sqlda );
Allocates space for each variable described in each descriptor of sqlda , and assigns the address of this memory to the sqldata field of the corresponding descriptor. Enough space is allocated for the database type and length indicated in the descriptor. Returns sqlda if successful and returns the null pointer if there is not enough memory available.
unsigned long sqlda_string_length( struct sqlda *sqlda, int varno );
Returns the length of the C string (type DT_STRING) that would be required to hold the variable sqlda->sqlvar[varno] (no matter what its type is).
unsigned long sqlda_storage( struct sqlda *sqlda, int varno );
Returns the amount of storage required to store any value for the variable described in sqlda->sqlvar[varno] .
struct sqlda *fill_s_sqlda( struct sqlda *sqlda, unsigned int maxlen );
Much the same as fill_sqlda, except that it changes all the data types in sqlda to type DT_STRING.. Enough space is allocated to hold the string representation of the type originally specified by the SQLDA, up to a maximum of maxlen bytes. The length fields in the SQLDA ( sqllen ) are modified appropriately. Returns sqlda if successful and returns the null pointer if there is not enough memory available.
void free_filled_sqlda( struct sqlda *sqlda );
Free the memory allocated to each sqldata pointer. Any null pointer is not freed. The indicator variable space, as allocated in fill_sqlda, is also freed.
void free_sqlda_noind( struct sqlda *sqlda );
Free space that was allocated to this sqlda . You should first call free_filled_sqlda to free the memory referenced by each sqldata pointer. The indicator variable pointers are ignored.
void free_sqlda( struct sqlda *sqlda );
Free the space allocated to this sqlda . You should first call free_filled_sqlda to free the memory referenced by each sqldata pointer. The indicator variable space, as allocated in fill_sqlda , is also freed.
|
|