ALLOCATE ROW statement
Use the ALLOCATE ROW statement to allocate memory for a row variable. This statement is an extension to the ANSI/ISO standard for SQL. Use this statement with ESQL/C.
Syntax
Element | Description | Restrictions | Syntax |
---|---|---|---|
variable | Name of a typed or untyped row variable to allocate | Must be an unallocated row-type host variable | Language specific |
Usage
- Declare the row variable. The row variable can be a typed or untyped row variable.
- Allocate memory for the row variable with the ALLOCATE ROW statement.
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.
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, assumes that the pointer is not valid and assigns it to a new memory location.