Distributed Transactions (OLE DB)
A distributed transaction is a transaction that updates data on two or more networked computer systems. If the provider supports distributed transactions, it exposes ITransactionJoin on the session. To determine whether the provider supports distributed transactions, the consumer calls QueryInterface to request an ITransactionJoin interface pointer on the session object. The consumer calls JoinTransaction on this interface pointer to enlist the session in a distributed transaction. After the consumer has joined a distributed transaction, it uses the ITransaction interface of the transaction coordinator to commit or abort the transaction. Consumers must set fRetaining to FALSE when committing or aborting a coordinated transaction. Following the commit or abort, ITransaction becomes invalid and the session is no longer part of a coordinated transaction.
It is an error to call ITransactionJoin::JoinTransaction if the session is already enlisted in a local transaction. In addition, the provider might require that any existing distributed transactions be committed or aborted before enlisting in a new distributed transaction. To unenlist from the transaction, the consumer calls ITransactionJoin::JoinTransaction on the session with pUnkTransactionCoord set to NULL.
If the consumer calls ITransactionLocal::StartTransaction to begin a local transaction while in a distributed transaction, that new transaction acts as a nested transaction within the distributed transaction. This is not supported by most providers.