sqlalloc() — Allocate Dynamic Memory
Allocates memory to hold the DATA (and INDICATOR) values for the SQLVAR_T component of the SQL descriptor area (SQLDA_T structure).
On successful completion,
sqlalloc()
returns a pointer to the allocated storage; otherwise it returns a 0 pointer value:
nbytes
The number of bytes to allocate for the DATA or INDICATOR components for an SQLVAR_T structure of the SQLDA_T structure. For the DATA component, you typically use a value for
nbytes
based on the SQL data type of the column (the TYPE component of the column’s SQLVAR_T structure). Include an extra byte for any NULL terminator or other extra characters that the data type uses. If you can set the column to the unknown value (i.e., the value of theNULLABLE
member of the SQLVAR_T structure is 1), also allocate storage for the INDICATOR component with the lengthsizeof
(long).NOTES
EXAMPLE
- This function returns a pointer to the allocated memory.
- The
sqlalloc()
function is a portable memory allocator. You may use your own memory allocation routines instead.- When allocating memory to hold the data values for column retrieval or parameter markers, the most effective technique is to obtain the column or parameter marker attribute information by calling
sqldyndesc()
(for columns) orsqldyndescinp()
(for parameter markers).- However you allocate storage, the precise allocation size depends on the data type of the column or parameter marker. Be sure to complete the allocation before retrieving columns or assigning parameter values to the SQLVAR_T structure.
In this example, the
for
statement assignspsqlvar
to each column (SQLVAR_T structure) of an SQL descriptor area (assumed to be allocated contiguously). The body of the loop allocates alloclen bytes to each data element, set according to the data type of the column. For a complete listing of this example, see thealloc_disp_cols()
function in thedyndemo.cc
sample ESQL source file provided with your installation:
SEE ALSO
sqlfree() — Deallocate Dynamic Memory,
proesql.h
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |