OpenTP1 Version 7 Programming Reference C Language

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

tx_open - Open a set of resource managers

Format

ANSI C, C++

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

K&R C

#include <tx.h>
int  tx_open()

Description

The function tx_open() opens a set of resource managers in a portable manner. It invokes a transaction manager to read information specific to the resource manager in a manner specific to the transaction manager and pass this information to the resource managers linked to the caller.

The function tx_open() attempts to open all resource managers that have been linked with the application. This function is used in place of open calls specific to the resource manager and allows an application program to be free of calls, which may hinder portability. Since resource managers differ in their initialization semantics, the specific information needed to open a particular resource manager must be published by each resource manager.

If tx_open() returns TX_ERROR, no resource managers are open. If tx_open() returns TX_OK, some or all of the resource managers have been opened. Resource managers that are not open return errors specific to the resource manager when accessed by the application. The function tx_open() must successfully return before a thread of control participates in global transactions.

Once tx_open() returns success, subsequent calls to tx_open() (before an intervening call to tx_close()) are allowed. However, such subsequent calls return success, and the TM does not attempt to reopen any RMs.

Return value

<<When return value is 0>>
Upon successful completion, tx_open() returns TX_OK, a non-negative return value. <<The set of one or more resource managers linked to the caller was opened.>>

Errors

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

Return value Return value (numeric) Explanation
TX_ERROR -6 Either the transaction manager or one or more of the resource managers encountered a transient error. No resource managers are open.
TX_FAIL -7 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.
Alternatively, an error occurred in the transaction manager because the execution environment was in non-journal operation mode.

See also

tx_close().

<<Example>>

<<if ( tx_open() <0)
    fputs ("cannot open resource manager\n", stderr);>>

<<Note on use with OpenTP1>>

  1. <<Only the resource managers conforming to the XA interface of X/Open can be opened with tx_open().>>
  2. <<tx_open() cannot used along with the function dc_trn_~().>>