dbenlistxatrans

DB Library for C

DB Library for C

dbenlistxatrans

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

Syntax

RETCODE debenlistxatrans (
    PDBPROCESS
dbproc,
    BOOL
enlisttran );

Arguments

dbproc

Is the DBPROCESS structure that is the handle for a particular workstation orSQL 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 are 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 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.

For information about using XA transactions through ODBC, see the SQL_COPT_SS_ENLIST_IN_XA connection option of the SQLSetConnectOption function.

See Also

dbenlisttrans