OpenTP1 Version 7 Programming Reference C Language

[Contents][Index][Back][Next]

tx_info - Return global transaction information

Format

ANSI C, C++

#include <tx.h>
int  tx_info (TXINFO *info)

K&R C

#include <tx.h>
int  tx_info (info)
TXINFO *info

Description

The function tx_info() returns global transaction information in the structure pointed to by info. In addition, this function returns a value indicating whether the caller is currently in transaction mode or not.

<<Argument>>

<<info>>

If info is non-null, tx_info() populates a TXINFO structure pointed to by info with global transaction information. The TXINFO structure contains the following elements:

XID                   xid;
COMMIT_RETURN         when_return;
TRANSACTION_CONTROL   transaction_control;
TRANSACTION_TIMEOUT   transaction_timeout;
TRANSACTION_STATE     transaction_state;

If tx_info() is called in transaction mode, xid is populated with a current transaction branch identifier and transaction_state contains the state of the current transaction. If the caller is not in transaction mode, xid is populated with the null XID (see <tx.h> for details). In addition, regardless of whether the caller is in transaction mode, when_return, transaction_control, and transaction_timeout contain the current settings of the commit_return and transaction_control characteristics, and the transaction timeout value in seconds.

The transaction timeout value returned reflects the setting that is used when the next transaction is started. Thus, it may not reflect the timeout value for the caller's current global transaction since calls made to tx_set_transaction_timeout() after the current transaction was begun may have changed its value.

If info is null, no TX_INFO structure is returned.

Return value

If the caller is in transaction mode, 1 is returned. If the caller is not in transaction mode, 0 is returned.

Errors

Under the following conditions, tx_info() fails and returns one of these negative values.

Return value Return value (numeric) Explanation
TX_PROTOCOL_ERROR -5 The function was called in an improper context (for example, the caller has not yet called tx_open()).
TX_FAIL -7 The transaction manager encountered a fatal error. The nature of the error is such that the transaction manager can no longer perform work on behalf of the application.

Application usage

Within the same global transaction, subsequent calls to tx_info() are guaranteed to provide an XID with the same gtrid component, but not necessarily the same bqual component.

See also

tx_open(), tx_set_commit_return(), tx_set_transaction_control(), tx_set_transaction_timeout().

<<Example>>

<<if (tx_info (NULL) !=1)
    fputs ("not transaction mode\n", stderr);>>