Transactions

For the DB2 access service, a transaction is equivalent to a unit of work (one or more requests). A transaction can span many requests.

Depending on DB2 access service property settings, the TransactionMode property that governs transaction behavior can be set to either short or long.

Short transactions

When short transactions are in effect, the DB2 access service is responsible for controlling the commitment of requests. After sending the request to the database, the DB2 access service automatically issues one of the following:

A begin transaction phrase can affect the behavior of a short transaction. If it receives a begin transaction phrase, the DB2 access service:

Long transactions

When long transactions are in effect, the client application is responsible for controlling when the transaction ends (by issuing either a commit or a rollback).

If the DB2 access service encounters a begin transaction phrase in a request, the phrase is ignored because the phrase does not affect the unit of work management.

The client application issues a commit or rollback statement for each transaction. When the client application closes its connection, the DB2 access service issues a rollback before exiting. Therefore, the client must commit any work that should be committed.

If the client application does not issue timely commit or rollback operations, then host resources (such as the APPC session or DB2 logging and locking) are held for an indeterminate amount of time. Therefore, long transactions can cause performance problems for other applications that need to access the same resource.

See the “Managing processing” section that follows for more information about the Allocate and StopCondition properties and how they interact with the transaction mode.