CommitTransaction

Description

Declares that the EAServer transaction associated with the calling thread should be committed.

Applies to

CORBACurrent objects

Syntax

CORBACurrent.CommitTransaction (breportheuristics )

Argument

Description

CORBACurrent

Reference to the CORBACurrent service instance

breportheuristics

A boolean specifying whether heuristic decisions should be reported for the transaction associated with the calling thread

Returns

Integer. Returns 0 if it succeeds and one of the following negative values if an error occurs:

Usage

The CommitTransaction function completes the transaction associated with the calling thread. Use the BeginTransaction function to begin a transaction and associate it with the calling thread. The transaction is not completed if any other participants in the transaction vote to roll back the transaction.

CommitTransaction can be called by a client or a component that is marked as OTS style. EAServer must be using the two-phase commit transaction coordinator (OTS/XA).

Examples

Example 1

In this example, the client calls the dopayroll method on the CmpnyAcct EAServer component, which processes a company payroll. The method returns 1 if the company has sufficient funds to meet the payroll, and the client then commits the transaction:

// Instance variables:
// CORBACurrent corbcurr
integer li_rc
boolean lb_rv
long ll_rc


// Create an instance of the CORBACurrent object
// and initialize it
...
lb_rv = corbcurr.BeginTransaction()
IF lb_rv THEN
    ll_rc = myconnect.CreateInstance(CmpnyAcct)
    // handle error
    li_rc = CmpnyAcct.dopayroll()
    IF li_rc = 1 THEN
      corbcurr.CommitTransaction(
    ELSE
      corbcurr.RollbackTransaction()
    END IF
ELSE
    // handle error
END IF

See also