BeginTransaction

Description

Creates an EAServer transaction and associates it with the calling thread.

Applies to

CORBACurrent objects

Syntax

CORBACurrent.BeginTransaction (  )

Argument

Description

CORBACurrent

Reference to the CORBACurrent service instance

Returns

Boolean. Returns true if it succeeds and false if the transaction could not be created.

Usage

The BeginTransaction function creates a transaction and modifies the transaction context of the calling thread so that it is associated with the transaction. This enables the calling thread to obtain information about the transaction and control commits and rollbacks. BeginTransaction 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). If the calling thread is already associated with a transaction, BeginTransaction returns false. Nested transactions are not supported.

Examples

Example 1

This example shows the use of BeginTransaction to create a transaction from a client:

// Instance variables:
// CORBACurrent corbcurr
// Connection myconnect
long ll_rc
integer li_rc1, li_rc2
boolean lb_success
ll_rc = myconnect.ConnectToServer()
// insert error handling ...
li_rc1 = this.GetContextService("CORBACurrent", &
    corbcurr)
// insert error handling ...
li_rc2 = corbcurr.Init( myconnect )
// insert error handling ...
lb_success = corbcurr.BeginTransaction()
IF NOT lb_success THEN    
MessageBox ("Create Transaction Failed", &
    "The client may already be in a transaction")
    RETURN

ELSE
    ll_rc = myconnect.CreateInstance(lcst_mybookstore)
    // begin processing
...

See also