10.07.2015 Views

Programming Guide - Actian

Programming Guide - Actian

Programming Guide - Actian

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

How You Can Access a Database with Standard SQL StatementsHow You Can Use the CursorObject System ClassIn OpenROAD, cursors are implemented as objects of the CursorObject systemclass. 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 rowsthat 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 havebeen processed.6. Close the cursor.CursorObject AttributesIt is only necessary to declare a cursor once in a program. You can open itmore than once, if you close it between each opening.Note: Opening a DataStream object in QY_CURSOR mode provides the samefunctions as using a cursor. For a discussion of using DataStream objects, seeHow You Can Access a Database with DataStream Objects (see page 165).The CursorObject class has three attributes that provide status information:StateContains information about the state of the cursor, such as whether it isopen or closedRowCountIndicates how many rows have been fetched successfully by the cursorsince the cursor was opened. When a cursor is opened, RowCount is set to0. Each subsequent successful fetch statement for that cursor incrementsRowCount by 1.When you close the cursor, the RowCount attribute is not reset to 0; itretains whatever value it had before the close statement executed. It isreset only if you reopen the cursor.DBSessionIdentifies the session in which the cursor was opened. After you open acursor, all subsequent cursor operations for that cursor automatically takeplace in the session in which the cursor was opened. If the frame isworking in a different session, OpenROAD automatically switches sessionsfor the cursor operation and switches back when the cursor statementcompletes.Working with a Database 159

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!