gtpc2m8xC/C++ Language Support User's Guide

tx_commit-Commit a Global Transaction

This function commits the work of the transaction that is activated by the entry control block (ECB) of a caller.

Format

#include   <tpfapi.h>
int         tx_commit();

Normal Return

Table 24. tx_commit Normal Return

Value Name Return Code Description
TX_OK 0 The function is completed successfully.

Error Return

Table 25. tx_commit Error Return

Value Name Return Code Description
TX_PROTOCOL_ERROR -5 The function was called incorrectly.

Programming Considerations

Examples

The following example shows how the tx_commit function is used to commit a nested transaction and then the root transaction.

#include   <tpfapi.h>
         tx_begin();                 /* begin a root transaction      */
              .
              .                      /* all RM native API calls will  */
              .                      /* be associated with the root   */
              .                      /* transaction                   */
              .
            tx_begin();              /* begin a nested transaction    */
              .
              .                      /* all RM native API calls will  */
              .                      /* be associated with the nested */
              .                      /* transaction                   */
              .
            tx_commit();             /* commit the nested transaction */
                                     /* all RM native API calls issued*/
              .                      /* from the nested transaction is*/
              .                      /* now associated with the root  */
              .                      /* transaction                   */
              .
         tx_commit();                /* commit the root transaction   */

Related Information