SQL/MP Programming Manual for C
Dynamic SQL Operations
HP NonStop SQL/MP Programming Manual for C—429847-008
10-12
Input Parameters and Output Variables
statement with an input SQLDA structure to get information about the input parameters 
and obtain pointers to the input values.
NonStop SQL/MP returns data to a program through output variables. Output variables 
are user-specified areas in the program. Output variables can be host variables or 
individual data buffers to which the program (through the SQLDA structure) contains 
pointers. Output variables usually contain columns returned from a SELECT operation. 
A program uses the DESCRIBE statement to get information about the output 
variables.
This sequence shows a typical context for input parameters and output variables in 
dynamic SQL. If you know in advance which columns are likely to be selected, you can 
use this sequence:
strcpy ( hostvar, "SELECT empnum, salary FROM =employee \
WHERE salary > ?sal"); /* input parameter sal */ 
/* Blank pad the statement buffer, dynamically compile */
/* the statement, describe its variables, prompt the */
/* user and read in the value for sal, declare and */
/* open a cursor for the statement. */
... 
EXEC SQL
 FETCH cursor INTO :enum, :sal; /* output variables */
 /* :enum and :sal */ 
If you do not know in advance which columns to select, you can send the output values 
to data buffers the program allocated earlier and to which the program set up pointers. 
The pointers are in the SQLDA structure. In this case, the FETCH statement would 
look like this:
EXEC SQL
 FETCH cursor
 USING DESCRIPTOR :sqlda; /* SQLDA contains pointers */ 
 /* to output data buffers. */ 
Internally, SQL execution is the same for both scenarios.
Using a Parameter List 
To ensure a one-to-one correspondence between a parameter list and the host 
variables you use to supply values for the parameters, use unnamed parameters. If 
duplicate parameter names appear in a statement, the names require a value for only 
the first occurrence, and the duplicate occurrences receive the same value. 
For example, suppose this UPDATE statement is stored in the host variable named 
update_statement: 
UPDATE table SET col1 = ?a, col2= ?a, col3 = ?b 










