Commit()
This method commits the database transaction.
Declaration
// C# public void Commit();
Exception
InvalidOperationException
– If the connection is closed or if the connection is enlisted in System.Transactions
.
System.ObjectDisposedException
– This property cannot be accessed after the OracleConnection
object is already disposed.
Remarks
This method allows the user to commit an implicit or explicit local transaction or active sessionless transaction using an OracleConnection
object. Once committed, the transaction ends. For local transactions, it has the same behavior as the OracleTransaction Commit
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 Commit
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 commit.