Cursors
Class
RWDBCursor of the DB Interface Module is implemented for Oracle OCI using a row-by-row fetch. The phrase
for update is appended to the
RWDBSelector or SQL statement when the cursor is constructed with
access = RWDBCursor::Write. For this reason, selected rows have exclusive locks. The use of cursors is subject to many restrictions:
Cursors are not directly supported by the OCI library, and therefore the same restrictions that apply to the OCI precompiler cursors apply to
RWDBCursor. The most severe restriction is that positioned updates or deletes can only be made to cursors created from a single table. Cursors created with a join of two tables cannot perform positioned updates or deletes.
Oracle OCI does support scrollable cursors in read-only mode. Backwards iteration can be achieved through repeated fetch calls of
RWDBCursor::Previous. Oracle OCI also supports calls to
RWDBCursor::Absolute and
RWDBCursor::Relative to navigate through your cursor result set. Scrollable cursors set to write mode will result in the error
RWDBStatus::notSupported.
Positioned deletes, inserts, and updates are implemented by constructing the appropriate SQL statement and executing the SQL statement using a second
OCIStmt*. The
RWDBCursor must be produced from within a transaction. The effect of the cursor update or delete won't be seen until the transaction is committed.
If an
RWDBCursor is created in write mode, using an SQL statement instead of an
RWDBSelector, and if the SQL statement is of the form
SELECT * FROM <table name>, then the cursor execution may produce the Oracle error “ORA-00923: FROM keyword not found where expected.” To work around this error, use table alias names. Specifically, use the SQL statement
SELECT t1.* FROM <table name> t1 or create the
RWDBCursor using an
RWDBSelector.