RollbackTransaction

Description

Rolls back the EAServer transaction associated with the calling thread.

Applies to

CORBACurrent objects

Syntax

CORBACurrent.RollbackTransaction (  )

Argument

Description

CORBACurrent

Reference to the CORBACurrent service instance

Returns

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

Usage

The RollbackTransaction function rolls back the transaction associated with the calling thread. The call fails if the HeuristicCommit exception is raised. Heuristic decisions are usually made when normal processing cannot continue, such as when a communications failure occurs. The HeuristicCommit exception is raised when all relevant updates have been committed.

RollbackTransaction 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

This example shows the use of RollbackTransaction to roll back a transaction when an update does not succeed:

// Instance variables:
// CORBACurrent corbcurr
int li_rc1, li_rc2
long ll_rc

this.GetContextService("CORBACurrent", corbcurr)
li_rc1 = corbcurr.Init()
IF li_rc1 <> 1 THEN
    // handle the error
ELSE
    ll_rc = CreateInstance(mycomp)
    // invoke methods on the instantiated component
    // test return values and roll back 

    // if unsatisfactory


    IF li_rc2 = 1 THEN
      corbcurr.CommitTransaction()
    ELSE
      corbcurr.RollbackTransaction()
    END IF

END IF

See also