>>-ALLOCATE ROW--variable--------------------------------------><
Element | Description | Restrictions | Syntax |
---|---|---|---|
variable | Name of a typed or untyped row variable to allocate | Must be an unallocated ESQL/C row-type host variable | Language specific |
The ALLOCATE ROW statement allocates memory for a host variable that stores row-type data. To create a row variable, an ESQL/C program must do the following:
The following example shows how to allocate resources with the ALLOCATE ROW statement for the typed row variable, a_row:
EXEC SQL BEGIN DECLARE SECTION; row (a int, b int) a_row; EXEC SQL END DECLARE SECTION; . . . EXEC SQL allocate row :a_row;
The ALLOCATE ROW statement sets SQLCODE (the contents of sqlca.sqlcode) to zero (0) if the memory allocation operation was successful, or 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.
When you use the same row variable in multiple function 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 the pointer is not valid and assigns it to a new memory location.
Related statements: ALLOCATE COLLECTION and DEALLOCATE ROW
For a discussion of complex data types in ESQL/C programs, see the IBM Informix ESQL/C Programmer's Manual.