Syntax 2: For TransactionServer objects
Description
Declares that the transaction in which a component is
participating should be committed and the component instance should be
deactivated.
Applies to
TransactionServer objects
Syntax
1 |
transactionserver.SetComplete ( ) |
Argument |
Description |
---|---|
transactionserver |
Reference to the TransactionServer service |
Return value
Integer.
Returns 1 if it succeeds and -1 if an error occurs.
Usage
The SetComplete function corresponds to the
completeWork 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 transaction is committed if either of the following
occurs:
-
The root component returns with a state of completeWork and no
participating component has set a state of disallowCommit. -
The root component is deactivated due to an explicit destroy
from the client and no participating component has set a state of
disallowCommit. (A client disconnect that is not preceded by an
explicit destroy request always causes a rollback.)
You can use the transaction state primitives in any component; the
component does not have to be declared transactional. Calling
completeWork or rollbackWork from methods causes early
deactivation.
Examples
The following example shows the use of SetComplete in a component
method that performs database updates:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
// 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