5. Embedded QUEL : Data Manipulation with Cursors : How You Open and Close Cursors
 
Share this page                  
How You Open and Close Cursors
You must open a cursor before you can use it to read, write, or delete data:
## open cursor cursor_name [for readonly]
When you open a cursor, it is positioned before the first row; the first retrieve cursor statement you issue advances the cursor to the first row and return its data. More than one cursor can be open at the same time.
You can use the for readonly clause if you do not intend to write or delete data; for readonly is valid even if the cursor was defined for direct|deferred update. Specifying for readonly can speed up processing. If you attempt to write data using a cursor that was opened readonly, the DBMS Server issues a runtime error.
The close statement terminates processing of a cursor:
## close cursor cursor_name
A cursor can be opened and closed any number of times; it must be closed, however, before it can be reopened. Closing and reopening a cursor repositions it to the top of the table.
Cursors cannot remain open across transactions; a cursor must be opened and closed within a single transaction.