Specify the name of a cursor that is defined in a DECLARE CURSOR statement appearing earlier in your program. When the OPEN statement is executed, the cursor must be in a closed state.
The result table of the cursor is derived by evaluating the SELECT statement, using the current values of any host variables specified in it. Two ways in which the rows of the result table can be derived are:
In either case, the cursor is placed in the open state and positioned before the first row of its result table (or after the last row, if the table is empty).
The USING clause introduces a list of host variables whose values are substituted for the parameter markers of the prepared select-statement. If the DECLARE CURSOR statement names a prepared statement that includes parameter markers, you must use USING. If the prepared statement does not include parameter markers, USING is ignored.
For more information on the USING clause, see the discussion about it in the section on the EXECUTE statement.
The USING clause is intended for a prepared select-statement that contains parameter markers. However, it can also be used when the select-statement of the cursor is part of the DECLARE CURSOR statement. In this case the OPEN statement is executed as if each host variable in the select-statement were a parameter marker. Thus the effect is to override the host variables in the select-statement of the cursor with the host variables specified in the USING clause.
A reference to each of its variables replaces reference to a structure when the statement is executed, where the number of variables must equal the number of parameter markers in the prepared statement, and the nth variable corresponds to the prepared statement's nth parameter marker.
Note: The OPEN is rejected with SQL error code -305 if the number of variables does not equal the number of parameter markers of host variables in the SELECT statement.
Parameter Marker Replacement: Each parameter marker in the query is effectively replaced by its corresponding host variable before the OPEN statement is executed. The replacement is an assignment operation in which the source is the value of the host variable and the target is a variable within CA Datacom/DB. The attributes of the target variable operand are the same as the left-most column reference operand or, if no column reference operand exists, the first non-parameter marker operand. If there are no operands, or if they are all parameter markers, or if the operator is concatenated, a parameter marker cannot be used, and the statement is rejected with SQL error code -302.
The value to which SQLD is set is required to be:
Note: The nth variable described by the SQLDA corresponds to the prepared statement's nth parameter marker.
|
Copyright © 2014 CA.
All rights reserved.
|
|