Rollback()
This method rolls back the local transaction.
Declaration
// C# public void Rollback();
Exception
InvalidOperationException
– If the connection is closed or if the connection is enlisted in System.Transactions
(both local and distributed).
System.ObjectDisposedException
– This property cannot be accessed after the OracleConnection
object is already disposed.
Remarks
This method allows the user to rollback a local transaction or sessionless transaction using an OracleConnection
object. Once rolled back, the transaction ends. For local transactions,it has the same behavior as the OracleTransaction Rollback
method. However, there are instances when this method is necessary to invoke without the OracleTransaction
object available, such as an implicit transaction using “SELECT … FOR UPDATE
” or an implicit transaction executing an INSERT
/UPDATE
/DELETE
statement with auto-commit disabled.
This method should not encounter any exceptions when the connection is within an explicit local transaction, implicit local transaction, or not associated with a transaction. This method cannot be executed on a connection enlisted in System.Transactions
(local or distributed).
When an explicit transaction begins, auto-commit is disabled regardless of the AutoCommit
property value. Once the Rollback
method is invoked, AutoCommit
reverts backs to true if it was earlier enabled. Transaction isolation level will also reset to its earlier value on the OracleConnection
object upon the rollback.