informix
Informix Guide to SQL: Syntax
SQL Statements

ALLOCATE ROW

Use the ALLOCATE ROW statement to allocate memory for a row variable.

Use this statement with ESQL/C.

Syntax

Element Purpose Restrictions Syntax
variable Name that identifies a typed or untyped row variable for which to allocate memory The variable must be an unallocated ESQL/C row host variable. Name must conform to language-specific rules for variable names.

Usage

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:

  1. Declare the row variable.
  2. The row variable can be a typed or untyped row variable.

  3. Allocate memory for the row variable with the ALLOCATE ROW statement.

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.

Example

The following example shows how to allocate resources with the ALLOCATE ROW statement for the typed row variable, a_row:

Related Information

Related statements: ALLOCATE COLLECTION and DEALLOCATE ROW

For a discussion of complex types, see the Informix ESQL/C Programmer's Manual.


Informix Guide to SQL: Syntax, Version 9.2
Copyright © 1999, Informix Software, Inc. All rights reserved