SQL/MX 2.x Reference Manual (H06.04+)

Embedded-Only SQL/MX Statements
HP NonStop SQL/MX Reference Manual540440-003
3-6
ALLOCATE DESCRIPTOR Statement
ALLOCATE DESCRIPTOR Statement
Considerations for ALLOCATE DESCRIPTOR
C Examples of ALLOCATE DESCRIPTOR
COBOL Examples of ALLOCATE DESCRIPTOR
The ALLOCATE DESCRIPTOR statement allocates a named SQL descriptor area
used for storing information necessary for the execution of dynamic SQL statements.
Use ALLOCATE DESCRIPTOR only in embedded SQL programs in C or COBOL.
descriptor-name
is a value-specification—a character literal or host variable with character
data type. When ALLOCATE DESCRIPTOR executes, the content of the host
variable (if used) gives the name of the descriptor area.
GLOBAL | LOCAL
specifies the scope of the allocated descriptor area. The default setting is LOCAL.
A GLOBAL descriptor area is available to the SQL session. A LOCAL descriptor
area is available only to the module or compilation unit in which it was allocated.
WITH MAX occurrences
specifies the maximum number of items in the descriptor area. occurrences
must be a host variable. The specified area must be large enough to store
information for as many parameters as you are using in your dynamic SQL
statements. The data type of occurrences must be exact numeric with scale 0
and a value of 1 or greater.
Considerations for ALLOCATE DESCRIPTOR
You should code the ALLOCATE DESCRIPTOR statement before the PREPARE
statement for the input descriptor. For example:
EXEC SQL ALLOCATE DESCRIPTOR 'in_desc' WITH MAX :desc_max;
printf("SQLCODE after allocate descriptor - 1 is %d\n",
SQLCODE);
strncpy(insert_buf, " ", sizeof(insert_buf));
strcpy(insert_buf, "insert into a5tab1 (select * from
a5tab0 where double1 between ? and double2/2);");
ALLOCATE DESCRIPTOR descriptor-name WITH MAX occurrences
descriptor-name is:
[GLOBAL | LOCAL] value-specification
C/COBOL