gtpc2m8w | C/C++ Language Support User's Guide |
This function places the calling entry control block (ECB) in transaction mode. The calling ECB must first ensure that the resource managers have been opened (using the tx_open() function) before it can start transactions.
Once in transaction mode, the calling ECB must call the tx_commit or tx_rollback function to complete its current transaction.
The TX specification published by X/Open Company Limited does not allow the tx_begin() function to be issued if the caller is already in transaction mode. However, the TPF implementation will allow the following calling sequences:
Format
#include <tpfapi.h> int tx_begin();
Normal Return
Table 22. tx_begin Normal Return
Value Name | Return Code | Description |
---|---|---|
TX_OK | 0 | The function is completed successfully. |
Error Return
Table 23. tx_begin Error Return
Value Name | Return Code | Description |
---|---|---|
TX_OUTSIDE | -1 | Resource managers are not opened. |
Programming Considerations
Examples
The following example shows how the tx_begin function is used to begin a root transaction and then a nested transaction.
#include <tpfapi.h> tx_begin(); /* begin a root transaction */ . . /* all RM native API calls will */ . /* be part of the root */ . /* transaction */ . tx_begin(); /* begin a nested transaction */ . . /* all RM native API calls will */ . /* be part of the nested */ . /* transaction */ . tx_commit(); /* commit the nested transaction */ /* all RM native API calls issued*/ . /* from the nested transaction */ . /* are now rolled in to the root */ . /* transaction */ . tx_commit(); /* commit the root transaction */
Related Information