|
|
OPEN
Usage
Description
The cursor is opened and references a set of rows in accordance with the definition of the cursor. The result-set is defined when the
OPENstatement is executed, any inserts, updates or deletes occurring after the open will not be reflected in the result-set. The cursor is placed `before' the first row in the addressed set.The
descriptor-nameis identified by a host variable or a literal.See ALLOCATE CURSOR for a description of extended cursors.
If the cursor is declared for a dynamically prepared
SELECTstatement, the source form of which contains parameter markers, theOPENstatement must include aUSINGclause.The first variable in the variable list or referenced in the descriptor area takes the place of the first parameter marker, the second variable takes the place of the second marker, and so on.
The number of variables provided in the
USINGclause must be equal to the number of parameter markers in the source statement, and the data types of the variables must be assignment-compatible with their usage in the source statement. See the Mimer SQL Programmer's Manual, Dynamic SQL, for a more detailed description of the use of dynamically prepared statements.Open cursors can be closed using one of the statements
CLOSE,COMMITorROLLBACK, except for cursors declaredWITH HOLDwhich remain open afterCOMMIT.An open cursor must be closed before it can be opened again, unless it is declared as
REOPENABLE.A cursor declared as
REOPENABLEcan have several open instances of a cursor. The state of the current instance is stored on a cursor stack when a new instance is opened. The state of the preceding cursor instance is restored when a cursor is closed, see CLOSE. In this context, the state of a cursor instance includes both the set of rows addressed by the cursor and the position of the cursor within the set.Restrictions
SELECTaccess is required to the table(s) or view(s) addressed by the cursor.
EXECUTEaccess is required to the result-set procedure addressed by the cursor.In a procedural usage context,
extended-cursor-namecannot be used to identify the cursor and neither of theUSINGoptions may be used.Notes
A cursor must be declared with a
DECLARE CURSORstatement or allocated with anALLOCATE CURSORstatement before it may be opened.All access rights that the current ident holds to the table(s) or view(s) addressed by the cursor are checked when the cursor is opened.
If
SELECTaccess is lacking, theOPENstatement will fail.If
UPDATEorDELETEaccess is lacking, the cursor may be opened but any correspondingUPDATE CURRENTorDELETE CURRENTstatements will fail.Only cursors declared for dynamically prepared statements may be opened with a USING clause.
Example
DECLARE c_1 CURSOR FOR SELECT product, producer, format, extract_date(release_date), price, item_id FROM product_details ... ... OPEN c_1; LOOP FETCH c_1 INTO c1_row; ... END LOOP; CLOSE c_1;For more information, see the Mimer SQL Programmer's Manual, Using Cursors.
Standard Compliance
|
Mimer Information Technology AB Voice: +46 18 780 92 00 Fax: +46 18 780 92 40 info@mimer.se |
|
|