Hitachi

Hitachi Advanced Database Application Development Guide


18.1.2 Transaction control

This subsection explains transaction start and termination and transaction control (commit and rollback processing).

Organization of this subsection

(1) Relationship between a connection and a transaction

Before starting a transaction, make sure that you establish a connection with the HADB server. No transaction can be started if a connection has not been established. You use the a_rdb_SQLConnect() CLI function to establish a connection.

When a connection that has been established is closed, the transaction is committed (the transaction terminates normally when the connection is closed without having to explicitly issue COMMIT from within the application program). You use the a_rdb_SQLDisconnect() CLI function to close the connection.

(2) Starting and terminating a transaction

A transaction starts when the application program acquires a statement handle. The transaction is terminated when COMMIT or ROLLBACK is executed. The following figure shows an example of transaction start and termination.

Figure 18‒2: Example of transaction start and termination

[Figure]

COMMIT and ROLLBACK for transactions are executed by using the a_rdb_SQLEndTran() CLI function.

When a definition SQL statement is executed, COMMIT processing is performed automatically.