EasyManua.ls Logo

HP NonStop SQL/MP

HP NonStop SQL/MP
331 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Dynamic SQL Operations
HP NonStop SQL/MP Programming Manual for C429847-008
10-26
Process the Output Variables
1. Get the length of the output names buffer from
sqlsa.u.prepare.output_names_len.
2. Call the allocate_sqlda function to allocate memory for the output SQLDA and
the output names buffer, if needed.
3. Initialize the SQLDA header fields (SQLDA_EYE_CATCHER is defined by the
C compiler):
*output_sqlda_ptr.eye_catcher = SQLDA_EYE_CATCHER;
*output_sqlda_ptr.num_entries = sqlsa.output_num;
4. Run a DESCRIBE statement to access the output variables:
EXEC SQL DESCRIBE :STATEMENT_NAME
INTO :*output_sqlda_ptr
NAMES INTO :*output_namesbuf_ptr;
5. Loop through the sqlvar array in the output SQLDA. Loop n times, where n is the
number of columns from sqlsa.u.prepare.output_num. On each iteration of
the loop:
a. Check the data_type field. If necessary, adjust the data type so the C
program can handle and reset data_len accordingly.
b. Allocate memory equal to data_len for the output column.
c. Set var_ptr to point to the memory.
d. If you are not allocating memory dynamically, you would have declared a
variable for each possible column value and put the address of the variable in
var_ptr.
e. If you know the number and data type of the output column values, you set
only data_type, data_len, and var_ptr.
f. Some programs might check data_type and data_len when the actual
values are obtained.
g. If you are handling null values, check the null_info field and continue
according to its value:
h. If necessary, set ind_ptr to point to the memory allocated in the previous
step. (If you are not allocating memory dynamically, define a variable for the
indicator and put its address in ind_ptr.)
6. To show column headings (similar to SQLCI), loop through the names buffer to
read the corresponding name for each column and display the column names.
0 Do not allocate any memory.
-1 Allocate two bytes of memory for the indicator variable.

Table of Contents

Related product manuals