In the following example, assume that you know the number and data types of the columns in the SELECT's result table when you code the application program.
To dynamically execute a fixed-list SELECT statement your program must:
EXEC SQL DECLARE CURSOR1 CURSOR FOR STMT;
EXEC SQL PREPARE STMT FROM :USERSTR;
EXEC SQL OPEN CURSOR1;
Alternately, if there were always two parameter markers in the statement:
EXEC SQL OPEN CURSOR1 USING :PARA1, :PARA2;
Or, to be more flexible, the input host variables could be described by an SQLDA, as in:
EXEC SQL OPEN CURSOR1 USING DESCRIPTOR :SQLDA-PARAS;
The application program in this case is required to ensure that the number of host variables described in the SQLDA matches the number of parameter markers in the SQL statement.
EXEC SQL FETCH CURSOR1 INTO :NAME, :PHONE;
EXEC SQL CLOSE CURSOR1;
|
Copyright © 2014 CA.
All rights reserved.
|
|