Skip navigation.

ATMI C Function Reference

  Previous Next vertical dots separating previous/next from contents/index/pdf Contents View as PDF   Get Adobe Reader

 


tx_begin(3c)

Name

tx_begin()—Begins a global transaction.

Synopsis

#include <tx.h> 
int tx_begin(void)

Description

tx_begin() is used to place the calling thread of control in transaction mode. The calling thread must first ensure that its linked resource managers have been opened (via tx_open()) before it can start transactions. tx_begin() fails (returning [TX_PROTOCOL_ERROR]) if the caller is already in transaction mode or tx_open() has not been called.

Once in transaction mode, the calling thread must call tx_commit() or tx_rollback() to complete its current transaction. There are certain cases related to transaction chaining where tx_begin() does not need to be called explicitly to start a transaction. See tx_commit() and tx_rollback() for details.

In a multithreaded application, a thread in the TPINVALIDCONTEXT state is not allowed to issue a call to tx_begin().

Optional Set-up

tx_set_transaction_timeout()

Return Value

Upon successful completion, tx_begin() returns TX_OK, a non-negative return value.

Errors

Under the following conditions, tx_begin() fails and returns one of these negative values:

[TX_OUTSIDE]

The transaction manager is unable to start a global transaction because the calling thread of control is currently participating in work outside any global transaction with one or more resource managers. All such work must be completed before a global transaction can be started. The caller's state with respect to the local transaction is unchanged.

[TX_PROTOCOL_ERROR]

The function was called in an improper context (for example, the caller is already in transaction mode). The caller's state with respect to transaction mode is unchanged.

[TX_ERROR]

Either the transaction manager or one or more of the resource managers encountered a transient error trying to start a new transaction. When this error is returned, the caller is not in transaction mode. The exact nature of the error is written to a log file.

[TX_FAIL]

Either the transaction manager or one or more of the resource managers encountered a fatal error. The nature of the error is such that the transaction manager and/or one or more of the resource managers can no longer perform work on behalf of the application. When this error is returned, the caller is not in transaction mode. The exact nature of the error is written to a log file.

See Also

tx_commit(3c), tx_open(3c), tx_rollback(3c), tx_set_transaction_timeout(3c)

Warnings

XA-compliant resource managers must be successfully opened to be included in the global transaction. (See tx_open(3c) for details.) Both the X/Open TX interface and the X-Windows system define the type XID. It is not possible to use both X-Windows calls and TX calls in the same file.

 

Skip navigation bar  Back to Top Previous Next