dbenlistxatrans

Enlists the current SQL Server connection in a transaction that is coordinated by an XA-compliant transaction processing (TP) monitor.

Syntax

RETCODE dbenlistxatrans (
PDBPROCESS
dbproc,
BOOL
enlisttran );

where

dbproc
Is the DBPROCESS structure that is the handle for a particular workstation/SQL Server process. It contains all the information that DB-Library uses to manage communications and data between the workstation and SQL Server.
enlisttran
Is TRUE or FALSE. TRUE specifies to enlist in the current XA transaction. False specifies to enlist in the NULL transaction, which results in the connection no longer being enlisted in any XA transaction.

When enlisttran is TRUE, the SQL Server connection is enlisted in the current XA transaction. All SQL operations performed using the SQL Server connection will be performed under the protection of the current XA transaction.

When enlisttran is FALSE, the SQL Server connection is no longer enlisted in any XA transaction. If you have used a SQL Server connection with an XA transaction, and you want to use the same SQL Server connection with a local SQL Server transaction, you must call dbenlistxatrans and pass a value of FALSE for the enlisttran parameter.

Returns

SUCCEED or FAIL.

Remarks

    To use XA transactions
  1. Call dbopen once for each SQL Server connection you want to establish.
  2. Call the X/Open tx_begin function to begin an XA transaction. tx_begin calls the appropriate XA-compliant TP monitor.
  3. For each SQL Server connection you want to enlist in the XA transaction, call dbenlistxatrans with enlisttran set to TRUE. Each call associates the current XA transaction with the specified SQL Server connection.
  4. Call dbsqlexec one or more times to perform SQL Server operations.
  5. Call the X/Open tx_commit function to commit the XA transaction.

    To perform a series of XA transactions, repeat steps 2 through 5.

See the SQL_COPT_SS_ENLIST_IN_XA connection option of the SQLSetConnectOption function for information about using XA transactions through ODBC.

See Also

dbenlisttrans