Allocates a SQL descriptor.
exec sql allocate descriptor descriptor_name [with max [host_variable | integer_literal]];
The name of the SQL descriptor that will contain information about the dynamic parameter markers in a prepared statement.
The maximum number of columns in the SQL descriptor.
An integer host variable defined in a declare section.
A numeric value representing the size, in number of occurrences, of the SQL descriptor.
exec sql begin declare section;
CS_INT type;
CS_INT numcols, colnum;
exec sql end declare section;
...
exec sql allocate descriptor big_desc
with max 1000;
exec sql prepare dynstmt from "select * from
huge_table";
exec sql execute dynstmt into sql descriptor
big_desc;
exec sql get descriptor :numcols = count;
for (colnum = 1; colnum <= numcols; colnum++)
{
exec sql get descriptor big_desc :type = type;
...
}
exec sql deallocate descriptor big_desc;
...
The allocate descriptor command specifies the number of item descriptor areas that Adaptive Server allocates.
You can allocate any number of SQL descriptors.
When a SQL descriptor is allocated, its fields are undefined.
If you try to allocate a SQL descriptor that is already allocated, an error occurs.
If you do not specify a value for the with max clause, one item descriptor is assigned.
When a SQL descriptor is allocated, the value of each of its fields is undefined.
deallocate descriptor, get descriptor, set descriptor