Managing Transaction State

The databases used by 4GL programs ensure that all database access, even read-only access, occurs within a transaction. A transaction is implicitly started when the first read or write occurs and lasts until the transaction is ended or the database connection is closed. While the transaction is active, the database will reserve resources for the application. These resources include, but are not limited to, connections, memory, read locks, write locks, file handles, and prepared statements.

The main purpose of transactions is to ensure that the application data is always in a consistent state. The classic example is transferring funds between accounts. Either the deposit and the withdrawal are both persisted to the database or neither is.

The secondary purpose of transactions is to release database resources, such as locks, that are held by your program while in a transaction. This includes the read-only locks used by read-only programs.