We have implemented a full support of TransactionScope in the OCI mode (the Direct=false; parameter in the connection string). You can also use TransactionScope in the direct mode (Direct=true;), but there will be only emulation of TransactionScope in this case, because a separate
OracleTransaction will be created for every connection in its scope. As a result:
a) the changes of one transaction will not be visible in another transaction of current TransactionScope. For example, the 131-st record will be inserted and updated within TransactionScope in the OCI mode, but only inserted (not updated) in the direct mode:
Code: Select all
using (TransactionScope ts = new TransactionScope()) {
using (OracleConnection conn = new OracleConnection(conStr))
{
conn.Open();
OracleCommand command = conn.CreateCommand();
command.CommandText = "insert into dept values
(131,'y','y')";
command.ExecuteNonQuery();
}
using (OracleConnection conn = new OracleConnection(conStr))
{
conn.Open();
OracleCommand command = conn.CreateCommand();
command.CommandText = "update dept set dname='xxxx'
where deptno=131";
command.ExecuteNonQuery();
}
ts.Complete();
}
b) two-phase commit is not supported in the direct mode. So it is possible the following scenario: two transaction in one TransactionScope are successfully executed, but, when committing, the second transaction fails (e.g. server failure) - the first transaction will be committed anyway, and TransactionScope will be "successfully" completed (without its 2-nd transaction).
Note TransactionScope is completed only on its disposing (not when calling Complete()). But it is necessary to call txScope.Complete() to complete your transaction.