Transactions handling

Informix® and IBM® DB2® handle transactions differently. The differences in the transactional models can affect the program logic.

Transactions in stored procedures:

Avoid using transactions in stored procedures to allow the client applications to handle transactions, in accordance with the transaction model.

Savepoints:

    SAVEPOINT name [UNIQUE]
    ROLLBACK [WORK] TO SAVEPOINT [name] ]
    RELEASE SAVEPOINT name
  1. Savepoints must be declared with the ON ROLLBACK RETAIN CURSORS clause
  2. Rollback must always specify the savepoint name

Solution

The Informix behavior is simulated with an autocommit mode in the IBM DB2 interface. A switch to the explicit commit mode is done when a BEGIN WORK is performed by the BDL program. Regarding the transaction control instructions, the BDL applications do not have to be modified in order to work with IBM DB2.

Note: If you want to use savepoints, always specify the savepoint name in ROLLBACK TO SAVEPOINT.

See also SELECT FOR UPDATE