Try OpenEdge Now
skip to main content
Developing AppServer Applications
Programming the AppServer : Managing transactions : Implementing automatic transactions : Controlling the transaction
 
Controlling the transaction
You can access the transaction object handle for the initialized transaction object using the TRANSACTION attribute on the procedure of any procedure executing in the AppServer session by using the THIS-PROCEDURE system handle, as shown:
DEFINE VARIABLE hTran AS HANDLE NO-UNDO.
hTran = THIS-PROCEDURE:TRANSACTION.
You can then access the transaction object methods and attributes to control the transaction, as described in the following table.
Table 4. Transaction handle methods and attributes
Method/Attribute
Return/Data type
Description
DEFAULT-COMMIT
LOGICAL
A writable attribute whose setting tells the transaction object how to complete any open automatic transaction if the transaction terminates with no prior invocation of the SET-COMMIT( ) or SET-ROLLBACK( ) method (for example, if the transaction initiating procedure is deleted). Setting it to TRUE ensures that the transaction is committed. Setting it to FALSE ensures that the transaction is rolled back. The default value is FALSE.
IS-OPEN
LOGICAL
A read-only attribute that returns TRUE if a transaction is active. The function of this attribute is identical to the ABL TRANSACTION function. See also the TRANS-INIT-PROCEDURE attribute.
SET-COMMIT( )
LOGICAL
Tells the transaction object to commit any active automatic transaction after the current request returns execution to the client. If no automatic transaction is active, the method returns FALSE.
Note that you cannot invoke this method after invoking a prior SET-ROLLBACK( ) within the same client request.
SET-ROLLBACK( )
LOGICAL
Tells the transaction object to roll back any active automatic transaction after the current request returns execution to the client. If no automatic transaction is active, the method returns FALSE.
Note that you can invoke this method after invoking a prior SET-COMMIT( ) within the same client request.
TRANS-INIT-PROCEDURE
HANDLE
A read-only attribute that returns the procedure handle to the transaction initiating procedure for any active automatic transaction. If no automatic transaction is active this attribute returns an invalid handle. (Validate with the VALID-HANDLE function.)