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.
Controls
TransactionServer objects
Syntax
|
1 |
<span>transactionserver</span>.<span>SetComplete</span> ( <span> </span>) |
|
Argument |
Description |
|---|---|
|
transactionserver |
Reference to the TransactionServer service |
Return Values
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 |
// Instance variables: |
|
1 |
// DataStore ids_datastore |
|
1 |
// TransactionServer ts |
|
1 |
Integer li_rc |
|
1 |
long ll_rv |
|
1 |
li_rc = this.GetContextService("TransactionServer", ts) |
|
1 |
IF li_rc <> 1 THEN |
|
1 |
// handle the error |
|
1 |
END IF |
|
1 |
... |
|
1 |
ll_rv = ids_datastore.Update() |
|
1 |
IF ll_rv = 1 THEN |
|
1 |
ts.<span>SetComplete</span>() |
|
1 |
ELSE |
|
1 |
ts.SetAbort() |
|
1 |
END IF |