An OPEN USING statement
You can execute the following statements with the OPEN...USING
statement:
- A parameterized SELECT statement (a SELECT statement that contains input parameters in its WHERE clause) that returns one or more rows
- A parameterized EXECUTE FUNCTION statement (a cursor function that contains input parameters for its arguments)
Tip: You cannot use an input parameter as the function
name for a user-defined function.
For example, the following
SELECT statement is a parameterized SELECT that requires two parameters
in its WHERE clause:
EXEC SQL prepare slct_id from
'select from orders where customer_num = ? and order_date > ?';
EXEC SQL declare slct_cursor cursor for slct_id;
If
the cust_num and ord_date host variables contain the
input parameter values, the following OPEN statement executes the
SELECT with these input parameters:
EXEC SQL open slct_id using :cust_num, :ord_date;
Use the USING host_var clause only when you know, at compile time, the type and number of input parameters in the WHERE clause of the SELECT statement.