OpenTP1 Version 7 Programming Reference C Language
tx_commit - Commit a global transaction
Format
ANSI C, C++
#include <tx.h> int tx_commit (void) |
K&R C
#include <tx.h> int tx_commit() |
Description
The function tx_commit() is used to commit the work of the transaction active in the caller's thread of control.
If the transaction_control characteristic (see tx_set_transaction_control()) is TX_UNCHAINED, when tx_commit() returns, the caller is no longer in transaction mode. However, if the transaction_control characteristic is TX_CHAINED, when tx_commit() returns, the caller remains in transaction mode on behalf of a new transaction (see the Return value and Errors sections below).
<<The values set by the following functions affect the processing of tx_commit()>>
Optional set-up
Return value
Errors
Under the following conditions, tx_commit() fails and returns one of these negative values.
Return value | Return value (numeric) | Explanation |
---|---|---|
TX_NO_BEGIN | -100 | The transaction committed successfully; however, a new transaction could not be started and the caller is no longer in transaction mode. This return value occurs only when the transaction characteristic is TX_CHAINED. |
TX_ROLLBACK | -2 | The transaction could not commit and has been rolled back. In addition, if the transaction_control characteristic is TX_CHAINED, a new transaction is started. |
TX_ROLLBACK_NO_BEGIN | -102 | The transaction could not commit and has been rolled back. In addition, a new transaction could not be started and the caller is no longer in transaction mode. This return value can occur only when the transaction characteristic is TX_CHAINED. |
TX_MIXED | -3 | The transaction was partially committed and partially rolled back. In addition, if the transaction_control characteristic is TX_CHAINED, a new transaction is started. |
TX_MIXED_NO_BEGIN | -103 | The transaction was partially committed and partially rolled back. In addition, a new transaction could not be started and the caller is no longer in transaction mode. This return value can occur only when the transaction characteristic is TX_CHAINED. |
TX_HAZARD | -4 | Due to a failure, the transaction may have been partially committed and partially rolled back. In addition, if the transaction_control characteristic is TX_CHAINED, a new transaction is started. This function returns TX_HAZARD even when you specify 00000001 for the trn_extend_function operand in the transaction service definition and the return value from the resource manager at one-phase commit is XAER_NOTA. |
TX_HAZARD_NO_BEGIN | -104 | Due to a failure, the transaction may have been partially committed and partially rolled back. In addition, a new transaction could not be started and the caller is no longer in transaction mode. This return value can occur only when the transaction characteristic is TX_CHAINED. This function returns TX_HAZARD_NO_BEGIN even when you specify 00000001 for the trn_extend_function operand in the transaction service definition and the return value from the resource manager at one-phase commit is XAER_NOTA. |
TX_PROTOCOL_ERROR | -5 | The function was called in an improper context (for example, the caller is not in transaction mode). The caller's state with respect to transaction is not changed. |
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. The caller's state with respect to the transaction is unknown. |
See also
tx_begin(), tx_set_commit_return(), tx_set_transaction_control(), tx_set_transaction_timeout().
<<Example>>
<<if (tx_info (NULL) == 1 && tx_commit() <0) fputs ("cannot commit transaction\n", stderr);>> |
<<Note on use with OpenTP1>>
All Rights Reserved. Copyright (C) 2006, 2010, Hitachi, Ltd.