SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
Dynamic SQL
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
9-6
Set Explicit Input Values
The SQL identifier sqlstmt is the name of the prepared statement to be used in a 
subsequent EXECUTE statement. The host variable hv_sql_statement contains 
the dynamic SQL statement.
Set Explicit Input Values
If you have dynamic input parameters in your prepared statement, you must code the 
appropriate C statements to prompt the user to input values and then store these 
values in the appropriate host variables.
Examples
/* Initialize input variable in WHERE clause. */
printf("Enter the employee number:"); 
scanf("%hu",&in_empnum); 
* Initialize input variable in WHERE clause.
 DISPLAY "Enter the employee number: ". 
 ACCEPT IN-EMPNUM.
Execute the Prepared Statement
You are ready to execute the prepared SQL statement. The EXECUTE statement 
names the input parameters and output variables. 
Use this general syntax: 
Before performing this operation, the application must store information for each input 
parameter of the prepared statement in the appropriate host variable. If you have more 
than one input parameter, supply the host variables for the parameters in the USING 
list in the order of the parameters’ position in the prepared SQL statement. 
When EXECUTE with INTO executes, NonStop SQL/MX stores information into the 
host variables (and optionally their indicator variables) that correspond to columns 
specified in the select list for the prepared statement. If you have more than one output 
variable, supply the host variables for the output variables in the INTO list in the order 
of the variables’ position in the prepared SQL statement. 
The number of arguments and the data types of arguments you provide in the 
EXECUTE statement must match the number of parameters and the data types of 
parameters in the prepared statement.
For complete syntax, see the EXECUTE statement in the SQL/MX Reference Manual.
EXECUTE SQL-statement-name 
 USING variable-spec [,variable-spec]...
 INTO variable-spec [,variable-spec]...;
C
COBOL










