NonStop Systems Introduction

Transaction Management
NonStop Systems Introduction527825-001
5-3
Specifying a TMF Transaction in a Program
$1050. To summarize, the purpose of TMF is to enable transactions to transform the
database from one consistent state to another consistent state.
Specifying a TMF Transaction in a Program
How do programmers take advantage of TMF benefits in applications? They simply
bracket the program statements that constitute a transaction with a pair of statements
that indicate the beginning and end of the transaction. TMF treats the entire bracketed
transaction as a single unit of recovery.
To mark the beginning and end of a transaction, the programmer uses statements such
as BEGIN TRANSACTION and END TRANSACTION. The actual statements depend
on which host language and API the programmer is using; typical statements are
shown in Table 5-1 on page 5-3.
Consider an example of a TMF transaction within an application. This example shows
an order-entry transaction written in a shorthand English form. These natural-language
statements serve to convey the major steps in the transaction:
BEGIN TRANSACTION
Read stock record from inventory database.
Enough stock?
Write order detail record to sales order database.
Need to reorder?
Issue purchase order to purchase order database.
Update stock record in inventory database.
END TRANSACTION
You can see that the transaction begins with a BEGIN TRANSACTION statement, and
this is what the programmer actually writes in the program. Then a number of program
statements follow. These statements specify that the transaction should read and write
records on various databases in the network. The work of the transaction is complete
when the END TRANSACTION statement is reached. You can think of these multiple
program steps as a single logical transaction because all the steps are related to a
single business function: placing a sales order.
Table 5-1. Typical Transaction-Delimiting Statements
Natural
Language TMF
NonStop
Tuxedo
ATMI SQL/MX
BEGIN
TRANSACTION
BEGINTRANSACTION() tpbegin() BEGIN WORK
END
TRANSACTION
COMMITWORK() tpcommit() COMMIT WORK
ABORT
TRANSACTION
ABORTTRANSACTION() tpabort() ROLLBACK WORK