![]() |
|
Use the ALLOCATE ROW statement to allocate memory for a row variable.
Use this statement with ESQL/C.
The ALLOCATE ROW statement allocates memory for a variable that stores row-type data. To create a row variable, perform the following steps in your ESQL/C program:
The ALLOCATE ROW statement sets SQLCODE (sqlca.sqlcode) to zero (0) if the memory allocation was successful and to a negative error code if the allocation failed.
You must explicitly release memory with the DEALLOCATE ROW statement. Once you free the row variable with the DEALLOCATE ROW statement, you can reuse the row variable.
Tip: The ALLOCATE ROW statement allocates memory for an ESQL/C row variable only. To allocate memory for an ESQL/C collection variable, use the ALLOCATE COLLECTION statement.
When you use the same row variable in multiple calls without deallocating it, a memory leak on the client computer results. Because there is no way to determine if a pointer is valid when it is passed, ESQL/C assumes that it is not valid and assigns it to a new memory location.
The following example shows how to allocate resources with the ALLOCATE ROW statement for the typed row variable, a_row:
Related statements: ALLOCATE COLLECTION and DEALLOCATE ROW
For a discussion of complex types, see the Informix ESQL/C Programmer's Manual.