Platform SDK: Transaction Server

IDtcToXaMapper::TranslateTridToXid

Used to obtain an XID from an ITransaction pointer and is called for every transaction that the connection is requested to be enlisted on.

HRESULT TranslateTridToXid (
DWORD *        pdwITransaction,
DWORD        dwRMCookie,
XID *                pXid);

Parameters

pdwITransaction [in]
A pointer to ITransaction interface which the application passes in as a value for the SQL_ENLIST_IN_DTC connection attribute.

dwRMCookie [in]
A cookie representing the RM which was obtained from the call to RequestNewResourceManager.

pXid [in/out]
A pointer to the XID structure.

Return Values

S_OK
Success.

E_INVALIDARG
One or more of the parameters are not valid.

XACT_E_NOTRANSACTION
No transaction corresponding to pdwITransaction.

Comments

This method is called to obtain an XID from an ITransaction interface pointer. The ITransaction pointer is offered by a transaction object. The transaction object contains a DTC transaction that is identified by a transaction identifier (TRID) which is a globally unique identifier (GUID). Given a TRID, one can always create an XID.

The XID should be stored in the connection object as it may be needed in the future. After obtaining the XID, the ODBC driver should issue an xa_start or its equivalent, meaning it should send the XID to the server (the resource manager back-end).