Allocates a SQL descriptor.
exec sql allocate descriptor descriptor_name [with max [host_variable | integer_literal]] end-exec
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 END-EXEC.
                 01    COLTYPE           PIC S9(9) COMP.
                 01    NUMCOLS           PIC S9(9) COMP.
                 01    COLNUM            PIC S9(9) COMP.
     EXEC SQL END DECLARE SECTION END-EXEC.
               ...
     EXEC SQL ALLOCATE DESCRIPTOR big_desc WITH MAX 1000 END-EXEC.
     EXEC SQL PREPARE dynstmt FROM "select * from huge_table" END-EXEC.
    *  Assume that the select returns only 1 row.
     EXEC SQL EXECUTE dynstmt INTO SQL DESCRIPTOR big_desc END-EXEC.
     EXEC SQL GET DESCRIPTOR big_desc :NUMCOLS = COUNT END-EXEC.
     MOVE 1 TO COLNUM.
     PERFORM GET-DESC-LOOP UNTIL COLNUM  > NUMCOLS.
     EXEC SQL DEALLOCATE DESCRIPTOR big_desc END-EXEC.
     EXEC SQL DEALLOCATE PREPARE dynstmt END-EXEC.
         ...
     GET-DESC-LOOP.
         EXEC SQL GET DESCRIPTOR big_desc VALUE
                 :COLNUM :COLTYPE = TYPE END-EXEC.
         DISPLAY "COLUMN ",COLNUM," IS OF TYPE ", COLTYPE.
         ADD 1 TO COLNUM.
The allocate descriptor command specifies the number of item descriptor areas that Adaptive Server Enterprise 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