Scalable Database Server, HiRDB Version 8 UAP Development Guide

[Contents][Index][Back][Next]

3.3.4 UAP transaction management in an OLTP environment

In OLTP, you cannot code the COMMIT and ROLLBACK statements. When synchronization point setting or transaction rollback occurs in a UAP executing in this environment, you must use an application program interface (API) that conforms to X/Open.

An example using OpenTP1 is explained here. For details about how to create a program by using OpenTP1, see the manual OpenTP1 Version 5 Program Reference C Language and the manual OpenTP1 Version 5 Program Reference COBOL Language.

A remote procedure call (RPC) can be used to implement one transaction among multiple OLTP user server processes. Each process is called a transaction branch, and the totality of these processes is called an OLTP global transaction.

When HiRDB is accessed from an OLTP global transaction, HiRDB cannot be accessed by the multiple transaction branches that make up the global transaction branch.

Sometimes when a resource is to be accessed, a timeout occurs because a lock on the resource was issued by a preceding transaction branch in the global transaction branch, thus causing a succeeding transaction branch to wait until the resource becomes available. Similarly, deadlock can occur between transaction branches.

The chain RPC function can be used in such a situation so that multiple RPCs can be treated as belonging to the same transaction branch.

Organization of this subsection
(1) C
(2) COBOL85

(1) C

(a) Transaction startup

Code the tx_begin function in the UAP.

(b) Setting synchronization points

Code the tx_commit function in the UAP.

(c) Setting rollbacks

Code the tx_rollback function in the UAP.

(2) COBOL85

(a) Transaction startup
DATA DIVISION.
 
*include TX definitions.
 
  01 TX-RETURN_STATUS
     COPY TXSTATUS.
 
PROCEDURE DIVISION.
CALL "TXBEGIN" USING TX-RETURN_STATUS.
(b) Setting synchronization points
DATA DIVISION.
 
*include TX definitions.
 
  01 TX-RETURN_STATUS
     COPY TXSTATUS.
 
PROCEDURE DIVISION.
CALL "TXCOMMIT" USING TX-RETURN_STATUS.
(c) Setting rollbacks
DATA DIVISION.
 
*include TX definitions.
 
  01 TX-RETURN_STATUS
     COPY TXSTATUS.
 
PROCEDURE DIVISION.
CALL "TXROLLBACK" USING TX-RETURN_STATUS.