Writing a commit marker to the transaction log

commit()

Write a commit marker to the transaction log


SYNTAX

commit()

The commit() function is used to mark the end of a section of code, any file updates in which are to be treated as a single entity, or transaction, for the purposes of transaction logging. The beginning of the section of code was marked by the begin() function. All Sculptor file updates (write, delete and insert) which take place within the marked code are recorded as part of the transaction, and the records are locked. The updates are at not yet permanent; they can be reversed by means of the rollback() function. The commit() function writes a ‘commit transaction’ marker to the transaction log file, indicating that the transaction is complete. All records locked by the transaction are unlocked and the updates become permanent.

This function returns 0 if successful or -1 if it fails. It should never fail with a Sculptor file; however, with some SQL databases it can return an error, especially if optimistic locking is used. This indicates that the transaction could not be committed because its updates conflict with another transaction. See ODBC record locking for more information.

If a program which has written a begin marker terminates, either normally or by means of an interrupt, without writing a commit, then Sculptor calls commit() automatically. This applies only to Sculptor file systems, and not to SQL databases such as Informix or Oracle.

See begin() for further details of transaction logging and the recovery program.


NOTES

  • A call to commit() with no matching begin() is ignored.

  • This function was introduced in Sculptor V. 5.1.0. Previously it was a command, commit, with very similar (but not identical) functionality. That command, now obsolescent, has been renamed commit_mark.


EXAMPLE

begin()
UpdateFiles()
commit()

RELATED TOPICS

begin()

rollback()

sys.Logging