SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)

Dynamic SQL With Descriptor Areas
HP NonStop SQL/MX Programming Manual for C and COBOL523627-004
10-3
Allocating an SQL Descriptor Area
Allocating an SQL Descriptor Area
Use the ALLOCATE DESCRIPTOR statement to allocate a named SQL descriptor
area to store information necessary for the execution of dynamic SQL statements. If
needed, allocate two descriptor areas: one for input parameters and one for output
variables.
Use this general syntax:
For complete syntax, see the ALLOCATE DESCRIPTOR statement in the SQL/MX
Reference Manual.
The descriptor name is a literal or a host variable with a character data type that
specifies an SQL identifier at run time. The number of occurrences is specified to be a
host variable whose value is the maximum number of item descriptors, or the number
of parameters to be used in the dynamic SQL statements in your program.
Deallocating an SQL Descriptor Area
After the execution of dynamic SQL statements in your program, use the
DEALLOCATE DESCRIPTOR statement to deallocate an SQL descriptor area
previously allocated with ALLOCATE DESCRIPTOR.
Use this general syntax:
For complete syntax, see the DEALLOCATE DESCRIPTOR statement in the SQL/MX
Reference Manual.
The descriptor name for both the ALLOCATE DESCRIPTOR and DEALLOCATE
DESCRIPTOR statements includes specifying a GLOBAL or LOCAL scope. The scope
must be the same for these two statements using the same descriptor name within the
same module or compilation unit.
Input Parameters
An input parameter is a symbol in a dynamic SQL statement that serves as a
placeholder for a value substituted when the statement executes.
Specify input parameters in the statement as question marks (?), and use them in SQL
expressions wherever a constant is valid. Using a parameter, you can prepare an SQL
statement without the input values, which are substituted when the statement
executes. Specify the data type of the parameter explicitly by using the CAST function
so that NonStop SQL/MX correctly types the parameter.
ALLOCATE DESCRIPTOR descriptor-name WITH MAX occurrences
DEALLOCATE DESCRIPTOR descriptor-name