Declares that a transaction on a transaction server should be rolled back.
To roll back a transaction |
Use |
---|---|
For OLETxnObject objects |
|
For TransactionServer objects |
Declares that the current transaction should be rolled back.
OLETxnObject objects
oletxnobject.SetAbort ( )
Argument |
Description |
---|---|
oletxnobject |
The name of the OLETxnObject variable that is connected to the COM object |
Integer. Returns 1 if it succeeds and -1 if an error occurs.
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.
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()
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.
TransactionServer objects
transactionserver.SetAbort ( )
Argument |
Description |
---|---|
transactionserver |
Reference to the TransactionServer service instance |
Integer. Returns 1 if it succeeds and -1 if an error occurs.
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.
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