SetAbort

Declares that a transaction on a transaction server should be rolled back.

To roll back a transaction

Use

For OLETxnObject objects

Syntax 1 For OLETxnObject objects

For TransactionServer objects

Syntax 2 For TransactionServer objects


Syntax 1 For OLETxnObject objects

Description

Declares that the current transaction should be rolled back.

Applies to

OLETxnObject objects

Syntax

oletxnobject.SetAbort (  )

Argument

Description

oletxnobject

The name of the OLETxnObject variable that is connected to the COM object

Returns

Integer. Returns 1 if it succeeds and -1 if an error occurs.

Usage

Call the SetAbort function from the client to force a COM+ transaction to be rolled back. The default is to complete the transaction if all participants in the transaction on the COM+ server have called SetComplete or EnableCommit.

Examples

Example 1

The following example shows the use of SetAbort in a component method that performs database updates:

integer li_rc

OleTxnObject lotxn_obj


lotxn_obj = CREATE OleTxnObject

li_rc = lotxn_obj.ConnectToNewObject("pbcom.n_test")

IF li_rc <> 0 THEN

	Messagebox( "Connect Error", string(li_rc) )

   // handle error

END IF


lotxn_obj.f_dowork()

lotxn_obj.f_domorework() 


IF /* test for client satisfaction */ THEN

		lotxn_obj.SetComplete()

ELSE

		lotxn_obj.SetAbort()

END IF

lotxn_obj.DisconnectObject()

See also

SetComplete


Syntax 2 For TransactionServer objects

Description

Declares that a component cannot complete its work for the current transaction and that the transaction should be rolled back. The component instance are deactivated when the method returns.

Applies to

TransactionServer objects

Syntax

transactionserver.SetAbort (  )

Argument

Description

transactionserver

Reference to the TransactionServer service instance

Returns

Integer. Returns 1 if it succeeds and -1 if an error occurs.

Usage

The SetAbort function corresponds to the rollbackWork transaction primitive in EAServer.

Any component that participates in a transaction can roll back the transaction by calling the rollbackWork primitive. Only the action of the root component (the component instance that began the transaction) determines when EAServer commits the transaction.

Examples

Example 2

The following example shows the use of SetAbort in a component method that performs database updates:

// Instance variables:

// DataStore ids_datastore

// TransactionServer ts


Integer li_rc

long ll_rv


li_rc = this.GetContextService("TransactionServer", ts)

IF li_rc <> 1 THEN

		// handle the error

END IF

...

...

ll_rv = ids_datastore.Update()

IF ll_rv = 1 THEN

		ts.SetComplete()

ELSE

		ts.SetAbort()

END IF

See also