commit work Statement

The commit work operation commits a transaction.

Syntax

commit {work|transaction} {then|else statement.block}

Description

This operation reliably logs all updates made since the last begin work statement to the database in atomic fashion. If the system halts during this process, the coldstart procedure automatically rolls forward the commit process when the machine recovers. If the commit process cannot be rolled-forward at that time (because of a missing file, trigger, and so on), then that transaction is rolled back. If the roll back fails, then the transaction is aborted and an error message displays on the screen and is printed to the errors file.

If the commit process fails under normal operations, then the entire transaction is undone and the else statement.block is taken, if present. Note that in this case, it is necessary to completely redo all updates performed by the transaction (after correcting the problem that led to the failure).

It is invalid to have a bridge or callx on a file that is updated within a transaction. The inclusion of these items can cause unpredictable results.

Example(s)

open "myfile" to f1

open "mylog" to f2

begin work

readu total from f1,"total"

total = total + 1

write total on f1,"total"

write total on f2,timedate();* create synchronized log

commit work else print "Could not update"

See Also

begin work Statement, transaction commit Statement, _CP_trans