DB Access Module for Oracle OCI User’s Guide : Chapter 2 Technical Information : Transaction Processing
Transaction Processing
Transactions can be controlled through Oracle OCI in two different ways:
by setting isolation levels
by using transaction control methods
Setting Isolation Levels
When connecting to an Oracle server, RWDBConnection::isolation() returns the isolation level of the connection to the server.
Table 5  shows the mapping between the Oracle session parameter and the isolation levels returned:
Table 5 – Oracle Isolation levels
Oracle Session Parameters
RWDBConnection::IsolationType
transaction_isolation_level = read_commited
ANSILevel1
transaction_isolation_level = serializable
ANSILevel3
Using Transaction Control Methods
You can explicitly control transactions through the following methods:
 
RWDBConnection::beginTransaction()
RWDBConnection::rollbackTransaction()
RWDBConnection::rollbackTransaction(const RWCString& savepoint)
RWDBConnection::commitTransaction()
RWDBConnection::setSavepoint(const RWCString& savepoint)
These methods have straightforward implementations that correspond to OCI calls like OCITransCommit(), OCITransRollback(), and SQL statements.
An application can add the DB Interface Module transaction methods to its code to take explicit control of its transaction blocks. However, transactions may not be nested as this feature is not supported by Oracle.
NOTE >> Oracle does not support nested transactions.
The savepoint feature is supported. The savepoint feature allows a current transaction to be partially rolled back to a marked point. The following example demonstrates the use of the savepoint feature and the other transaction processing methods of the DB Interface Module.
 
// Assume we have a table myTable(c int) with no rows in it.
RWDBInserter ins= myTable.inserter();
 
cn1.beginTransaction (); // Begin transaction..
 
(ins << 1).execute(cn1); // First insertion
...
cn1.setSavepoint("svp1"); // Save first insertion
 
(ins << 2).execute(cn1); // Second insertion
(ins << 3).execute(cn1); // Third insertion
 
cn1.rollbackTransaction("svp1"); // Roll back second and
// third insertions
cn1.commitTransaction(); // Commit transaction on
// part that is not rolled back
The above program results in myTable holding one row of data. Its value is 1.