Which
PowerScript function
Description
Allows a component to find out whether it is running on a
transaction server.
Applies to
TransactionServer objects
Syntax
|
1 |
transactionserver.Which ( ) |
|
Argument |
Description |
|---|---|
|
transactionserver |
Reference to the TransactionServer service instance |
Return value
Integer.
Returns 0 if the object is not running on a transaction server, 1 if
it is running on EAServer (obsolete), or 2 if it is running on
COM+.
Usage
The Which function allows a custom class user object to perform
different processing depending on its runtime context.
Examples
The code in the following example checks to see whether the runtime
context is a transaction server. If it is, it uses transaction semantics
that are appropriate for a transaction server; otherwise, it uses COMMIT
and ROLLBACK to communicate directly with the database:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
// 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 ts.Which() > 0 THEN IF ll_rv = 1 THEN ts.EnableCommit() ELSE ts.DisableCommit() END IF ELSE IF ll_rv = 1 THEN COMMIT USING SQLCA; ELSE ROLLBACK USING SQLCA; END IF END IF |
See also