(Contents)(Previous)

Transactions

ADABAS is a transaction-oriented database system with reset facility.

This means that a safety mechanism runs parallel to ADABAS. This mechanism allows any modifications made to the database to be cancelled. The statement

ROLLBACK WORK

restores the status as it was at the beginning of a session. While working with the database, the user has the possibility to define the point in time up to which modifications to the database are reset. This point in time can be redefined by using the statement

COMMIT WORK

Whenever COMMIT WORK is issued, a 'transaction' is concluded.

This means in practice that the activities can be tried out first and then, when the user is satisfied with the results, the status reached so far can be saved permanently using COMMIT WORK, thus becoming the starting point of the next transaction. If, on the other hand, errors and undesired effects have occurred, these can be cancelled using ROLLBACK WORK, thus returning to the last point where the database has been saved.

Example:

COMMIT WORK

SELECT cno, firstname, name, account

FROM person

UPDATE person SET account = 0

WHERE account > -10 AND

account <= 0

SELECT cno, firstname, name, account

FROM person

ROLLBACK WORK

SELECT cno, firstname, name, account

FROM person

So-called subtransactions can be used within transactions to define logical units. Subtransactions can be nested.

A subtransaction is opened with SUBTRANS BEGIN; if it was successful, it is closed with SUBTRANS END. If the modifications are not desired, they can be rolled back by using SUBTRANS ROLLBACK.

Related to the transaction concept is the locking concept.

There are two kinds of locks. Setting a read lock allows all users to read the locked object, but prevents them from modifying it. To alter an object, the user needs a write lock which prevents other users from read- or write-accessing the object.

Locks are generally implicitly set by the system and are kept up to the transaction's end. But the user can also set them explicitly for certain areas by using the LOCK statement. These locks are held up to the transaction's end, as well.

The user indicates the lock mode he wants to work with, specifying an isolation level. ADABAS distinguishes the isolation levels 0, 10, 15, 20, 30. The larger the number, the better the consistency ensured for the read data. But this will have a negative effect on the possible concurrency of data accesses. See also the ADABAS Reference Manual.

In precompiler programs, the CONNECT statement can be used to make known the LOCK mode.


(Contents)(Previous)