5. Working with a Database : How You Can Access a Database with Standard SQL Statements : How You Can Use Cursors to Access the Database : How You Can Use the CursorObject System Class
 
Share this page                  
How You Can Use the CursorObject System Class
In OpenROAD, cursors are implemented as objects of the CursorObject system class. Using a cursor consists of the following steps:
1. Declare a CursorObject reference variable.
2. Open the cursor, specifying whether the cursor can update or delete rows that are fetched.
3. Fetch a row and move the values in the row into variables.
4. Optionally update or delete the row on which the cursor is positioned, using the values loaded into the variables.
5. Generally, repeat Steps 3 and 4 until all the rows in the result table have been processed.
6. Close the cursor.
It is only necessary to declare a cursor once in a program. You can open it more than once, if you close it between each opening.
Note:  Opening a DataStream object in QY_CURSOR mode provides the same functions as using a cursor. For a discussion of using DataStream objects, see How You Can Access a Database with DataStream Objects (see How You Can Access a Database with DataStream Objects).