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-3
Steps for Using Dynamic SQL With Argument Lists
and dynamic parameters. See the SQL/MX Reference Manual for information on
setting CONTROL QUERY DEFAULT values.
Steps for Using Dynamic SQL With Argument
Lists
Figure 9-1 shows the steps presented within the complete C program. These steps are
executed in the sample program Example A-3 on page A-5.
Figure 9-1. Using Dynamic SQL in a C Program
...
EXEC SQL BEGIN DECLARE SECTION;
char hv_sql_statement[256];
long in_value;
... hv_column1;
... hv_column2;
...
EXEC SQL END DECLARE SECTION;
... /* Construct the SQL statement and move to statement variable. */
...
EXEC SQL PREPARE sqlstmt FROM :hv_sql_statement;
...
... /* Prompt user for value of input parameter. */
scanf("%hu",&in_value);
EXEC SQL EXECUTE sqlstmt USING :in_value
INTO :hv_column1,:hv_column2,...;
EXEC SQL DEALLOCATE PREPARE sqlstmt;
C
1
2
3
4
5
6