Dynamic SQL Operations
HP NonStop SQL/MP Programming Manual for C—429847-008
10-31
Allocate Memory for the SQLDA Structures and
Names Buffers
Allocate Memory for the Values
After the descriptions of input parameters and output variables are specified, the
program must allocate space for the actual values. The user might enter these values
for input parameters, or the system might return them for columns (output variables).
These paragraphs describe how to handle input parameters.
The program uses the DESCRIBE INPUT statement to fill in the SQLDA and names
buffer with the descriptions of input parameters in the SQL statement. If you specify
NAMES INTO, the names of the parameters are also returned in the names buffer. For
a statement whose name was stored in a statement host variable, the DESCRIBE
INPUT statement is as follows:
EXEC SQL
DESCRIBE INPUT :statement_name
INTO :*input_sqlda_ptr
NAMES INTO :*input_namesbuf_ptr;
The DESCRIBE INPUT statement places the descriptions for parameters into the input
SQLDA and the names of parameters into the location pointed to by
input_namesbuf_ptr
.
Immediately after DESCRIBE INPUT runs, the
var_ptr
field in the SQLDA points to
the first entry in the names buffer. You can use
var_ptr
to read the names from the
names buffer only if you access the names buffer immediately following the
DESCRIBE INPUT or DESCRIBE statement. After you have set
var_ptr
to point to
the data, you can no longer use
var_ptr
to access the names buffer and must loop
through the names buffer to get the names.
The program can now allocate memory for the parameter values to be entered.
Handle Scale
If your program must handle numeric values with scale, read the scale information from
the input SQLDA structure. The DESCRIBE INPUT statement places this information
in bits 0 through 7 of the data_len field in the SQLVAR array.
If you can ignore scale, you can set the
data_len
field to 0, causing data truncation.
Otherwise, save the scale information and write a function to handle scale. Your
program must check the data type of the values input to the program. For declarations
that represent the data types that you can use in your program, see
Table 10-4
on
page 10-8. To include declarations for these literals, use the #include directive to copy
the
sqlh
file.
Summary of Contents for NonStop SQL/MP
Page 4: ......
Page 14: ...Contents HP NonStop SQL MP Programming Manual for C 429847 008 x ...
Page 60: ...Host Variables HP NonStop SQL MP Programming Manual for C 429847 008 2 26 VARCHAR Data Type ...
Page 294: ...SQL MP Sample Database HP NonStop SQL MP Programming Manual for C 429847 008 A 6 ...