Description
This interface supports Distributed Transactions for MS-SQL database that are controlled by MS-DTC engine (Microsoft Distributed Transaction Coordinator).
DTC is a system service that coordinates transactions so that work can be committed as an atomic transaction even if it spans multiple resource managers on multiple computers, regardless of failures.
This interface is applicable for the following environment:
- MS-SQL database server
- C/C++ interface
- ODBC connection type
- DI API only (and not by DI Server)
Property type
Read-write property
Syntax
Visual Basic |
---|
Public Property DTCTransactionObject() As Unknown |
Remarks
Usage
- Create a distributed transaction object externally to the application using the DTC interface.
GetDTCInterface (&g_pTransactionDispenser);
g_pTransactionDispenser->
BeginTransaction(NULL, ISOLATIONLEVEL_ISOLATED, ISOFLAG_RETAIN_DONTCARE, NULL, (::ITransaction**)&g_pTransaction);
- The DI COM module receives a handle to a live transaction that is created by the MS-DTC.
ICompanyPtr pCmp; pCmp->put_DTCTransactionObject (g_pTransaction);
- The DI performs a validation of the transaction object by verifying its Isolation Level. After the validation succeeds, the DB module is notified that the current transaction is an outside object and managed externally.
- The transaction process is performed as usual, and the change in the flow is transparent to the user. During a DTC Transaction, do not call StartTransaction() and EndTransaction(), otherwise the system returns an error.
- To end the DTC transaction, assign a NULL value to the DTC Transaction handle:
pCmp->put_DTCTransactionObject (NULL);
- To get the current DTC handle that is set in SAP Business One, call:
IUnknown* ptr = NULL;
HRESULT hr = pCmp ->get_DTCTransactionObject(&ptr);
- To check whether a DTC Transaction is set, call:
bool isDTCSet;
pCmp->IsDTCTransactionObjectSet(&isDTCSet);
Notes
- In case an operation fails during a DTC transaction, SAP Business One performs a rollback, which forces other systems under the same distributed transaction to rollback.
- The DTC transaction scope (the Begin/End user transaction equivalent) is determined by the calls to put_DTCTransactionObject ().
As long as there is a transaction object set, every operation is performed under this transaction context. It is the Client's responsibility to make sure a valid DTC transaction is assigned, and to assign NULL value when the DTC transaction ends. - StartTransaction() and EndTransaction() must not be called during a DTC Transaction.
- put_DTCTransactionObject () must not be called during a live user transaction.