Share via


Transaction Management

OLE DB defines a basic set of interfaces for transaction management. A transaction enables consumers to define units of work within a provider. These units of work have the atomicity, concurrency, isolation, and durability (ACID) properties. Transactions allow the specification of various isolation levels to enable more flexible access to data among concurrent consumers.

Local Transactions

Local transactions refer to transactions running in the context of a resource manager. A provider that supports transactions exposes ITransactionLocal on the session. A call to ITransactionLocal::StartTransaction begins a transaction on the session. A session can be inside or outside of a transaction at any time. When created, a session is outside of a transaction and all the work done under the scope of the session is immediately committed on each OLE DB method call. When a session enters a local or coordinated transaction, all the work done under the session ? between the ITransactionLocal::StartTransaction and ITransaction::Commit or ITransaction::Abort method calls and including other objects created underneath it (commands or rowsets) ? is part of the transaction.

ITransactionLocal::StartTransaction supports various isolation levels that consumers can request when creating a transaction. OLE DB providers do not need to support all possible transaction options defined. A consumer can interrogate the transaction capabilities of a provider through IDBProperties.

For providers that support nested transactions, calling ITransactionLocal::StartTransaction within an existing transaction begins a new nested transaction below the current transaction. Calling ITransaction::Commit or ITransaction::Abort on the session commits or aborts, respectively, the transaction at the lowest level.

Distributed Transactions

OLE DB defines an interface, ITransactionJoin, for consumers to request that providers enlist in a coordinated transaction among multiple (possibly distributed) data providers and other types of resource managers. The details of how providers enlist themselves as resource managers with the transaction coordinator are described in the Component Services (or Microsoft Transaction Server if you are using Microsoft? Windows NT?) documentation.

For more information about transactions, see Transactions.