Navigation: ABC Library Reference > TransactionManager >====== TransactionManager Overview ====== | |
The TransactionManager class is used to manage a transaction processing “frame”. It wraps all of the classic operations normally used in a typical transaction process, including LOGOUT, COMMIT, and ROLLBACK operations, and allows you to control them through a simple set of methods. Nearly all ISAM and SQL tables support transaction processing. Please refer to the Database Drivers Help topic for more specific information regarding each individual driver.
TransactionManager Concepts
Override and Control of one or all of the Template-Based Transaction Frames
In a standard application created in the Application Generator, transaction processing of data elements is handled by the target RelationManagers for each primary table. The ABC Templates set the RelationManager's UseLogout property based on the Enclose RI code in transaction frame check box in the Global Properties dialog. You can use the TransactionManager (with the help of the supporting templates) to turn off the RelationManager support for transaction framing, and specifically customize the tables that you need to enclose in a transaction frame in a target Form or Process procedure.
Simplified Custom Transaction Processing
All of your hand-coded transaction processing frames can now be encapsulated in the TransactionManager. Using its available methods ensures that proper initialization, processing, and error checking will be performed.
TransactionManager ABC Template Implementation
The TransactionManager is supported by two Extension templates. The Save Button Transaction Frame extension template is used to control transaction processing via the TransactionManager in any Form (update) procedure that uses the Save Button control template. Using the Process Transaction Frame extension template, you can override and control any needed transaction processing that needs to be applied in any process procedure.
The Process Transaction Frame Checkpoint code template is used in any process procedure to specify and control transaction processing over a specific batch of records instead of the normal default processing of individual records.
TransactionManager Relationship to Other Application Builder Classes
The TransactionManager is closely integrated with RelationManager objects. These objects are added to a protected TransactionManagerQueue, where a reference to each RelationManager object and thread instance is stored.
TransactionManager Source Files
The TransactionManager source code is installed by default to the Clarion \LIBSRC folder. The TransactionManager source code and its respective components are contained in:
ABFILE.INC | TransactionManager declarations |
ABFILE.CLW | TransactionManager method definitions |
TransactionManager Conceptual Example
The following examples show a typical sequence of statements to declare, instantiate, initialize, use, and terminate a TransactionManager.
!This example shows all that is needed to implement transaction processing
!using the TransactionManager
MyTransaction TransactionManager
ReturnValue BYTE
CODE
Relate:Invoice.Open()
MyTransaction.AddItem(Relate:Invoice)
MyTransaction.AddItem(Relate:Items)
ReturnValue = Level:Benign
IF MyTransaction.Start()=Level:Benign !Initialize, begin LOGOUT
!……
!Work with the Tables here and set the ReturnValue to Level:Fatal
!if there are any errors.
!……
MyTransaction.Finish(ReturnValue) !Commit or rollback based on errorlevel
END
!——————————————————————–
!This next partial code example demonstrates how to execute the transaction
!in a process. It uses the SetLogoutOff\RestoreLogout methods. This is used
!when you need a longer transaction in a process where you don't need to
!continually set the Uselogout to TRUE/FALSE repeated times (via Start)
………..
MyTransaction.AddItem(Relate:Invoice)
MyTransaction.AddItem(Relate:Items)
MyTransaction.SetLogoutOff()
………..
ReturnValue = MyTransaction.Start()
………..
………..
MyTransaction.Finish(ReturnValue)
ReturnValue = MyTransaction.Start()
………..
………..
MyTransaction.Finish(ReturnValue)
………..
MyTransaction.RestoreLogout()
………..
! ——————————————————————–
!This example shows the use of the Process virtual method.
PROGRAM
MAP.
MyTransaction CLASS(TransactionManager)
Process PROCEDURE(),BYTE,VIRTUAL
END
ReturnValue BYTE
CODE
Relate:Invoice.Open()
MyTransaction.AddItem(Relate:Invoice)
MyTransaction.AddItem(Relate:Items)
MyTransaction.Run()!This will all the work for you
MyTransaction.Process PROCEDURE()
ReturnValue BYTE
CODE
ReturnValue = Level:Benign
!Work with the Tables here and set the ReturnValue to Level:Fatal
!if there are any errors.
RETURN ReturnValue