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-8
Consideration—Retrieving Multiple Values From a
Large Buffer
If you are retrieving the value of an output variable from the VARIABLE_DATA field in
the descriptor area, the receiving host variable must be of a compatible data type and
size for the information being retrieved. Retrieve the output values in the
VARIABLE_DATA field by using the GET DESCRIPTOR statement within the COUNT
loop and by testing on TYPE or NAME to assign the value to the host variable. In
addition, you cannot use arithmetical computation with the VARIABLE_DATA field.
Typically, columns that are not known to the static compiled program are fetched by a
dynamic SQL cursor when the cursor specification is provided by the user. For an
example of this method, see Section 11, Dynamic SQL Cursors.
Consideration—Retrieving Multiple Values From a Large Buffer
To retrieve multiple values efficiently from a large buffer, consider using
VARIABLE_POINTER. In this case, use GET_DESCRIPTOR once to retrieve pointers
to individual values. Otherwise, you must use GET_DESCRIPTOR multiple times to
retrieve each individual value.
A typical statement sequence using VARIABLE_POINTER consists of:
1. DESCRIBE_OUTPUT statement
2. SET_DESCRIPTOR statement with VARIABLE_POINTER (set up pointers to
individual values)
3. EXECUTE statement
4. FETCH statement (obtain data)
5. GET_DESCRIPTOR statement (obtain pointers to data)
VARIABLE_POINTER is described in the SET DESCRIPTOR statement in the
SQL/MX Reference Manual. Example 10-1 describes how to use
VARIABLE_POINTER in a C program.