Platform SDK: Transaction Server

Implementing Algorithms

The ODBC drivers are expected to implement several high-level algorithms in order to be fully integrated with MS DTC and, therefore, with Microsoft Transaction Server:

On SQL_ENLIST_IN_DTC with a Non-NULL Transaction Value

if  (Connection_State   EQUALS   LOCAL_TRANSACTION_STATE) then
do begin
invoke pIDtcToXaMapper->RequestNewResourceManager (    “Accounts”,  
“SQLODBC32.DLL”, 
&dwRMCookie)

do close the database if it is open
do xa_open or its equivalent

set Connection_State to DISTRIBUTED_TRANSACTION_MODE
end if

invoke pIDtcToXaMapper->TranslateTridToXid     (    pITransaction, 
    dwRMCookie,
    &XID
);
do xa_start or its equivalent

invoke pIDtcToXaMapper->EnlistResourceManager (dwRMCookie, pITransaction)

do xa_end or its equivalent if needed

On SQL_ENLIST_IN_DTC with a NULL Transaction Value

if (Connection_State EQULS LOCAL_TRANSACTION_STATE) then
    return ERROR_UNEXPECTED_CALL

set Connection_State to LOCAL_TRANSACTION_MODE

do xa_close or its equivalent if needed