TMF Introduction (G06.24+)

Transaction Coordination
HP NonStop Transaction Management Facility (TMF) Introduction522414-001
2-8
Transaction Definition by the Application
Abort Transaction
The application aborts (cancels) a TMF transaction, indicating that any database
changes made since the begin-work designation are to be undone.
TMF undoes any of the work performed by the transaction on audited files, and
ensures that no part of the work is applied to the database.
Transaction Control Statements in Programs
To designate the transaction control operations, application programmers may include
transaction control statements in their programs. They can put these statements in any
appropriate module of the application.
The syntax to specify these transaction control operations is different for different
programming languages and application programming interfaces (APIs), as shown in
Table 2-1.
Transaction control statements in an embedded SQL application are illustrated in
Example 2-1
.
Table 2-1. Sample Transaction Control Statements
Language
or API Begin Transaction End Transaction Abort Transaction
SQL BEGIN WORK COMMIT WORK ROLLBACK WORK
TMF API BEGINTRANSACTION ENDTRANSACTION ABORTTRANSACTION
Guardian
System
Procedure
Calls (TAL)
BEGINTRANSACTION ENDTRANSACTION ABORTTRANSACTION
SCREEN
COBOL
BEGIN-TRANSACTION END-TRANSACTION ABORT-TRANSACTION
Example 2-1. Transaction Control Using Embedded SQL
EXEC SQL BEGIN WORK;
...
EXEC SQL UPDATE ...;
...
if (!strcmp(SQLSTATE, SQLSTATE_OK))
EXEC SQL COMMIT WORK;
else
EXEC SQL ROLLBACK WORK;