14.10.3 Transactions
Transactions make it possible to alter, add or delete several database
records and guarantee that all changes, or no changes, will be accepted
by the database. A transaction object is basically a table object with
a few restrictions and additions, listed below:
- Purge is not available in a transaction object.
- Commit. In order to make all changes take affect, commit must be
issued at the end of a transaction sequence. Changes done by a
transaction object will never take affect before commit,
even if the database is shut down, the program crashes etc.
- Rollback. A rollback cancels all changes made by the transaction object.
Rollbacks always succeeds. However, with commit that is not always
the case. A commit will fail if:
- A record that is altered by the transaction object is altered
again by something else, before commit. This is called a conflict,
and will result in an error upon commit.
- METHOD
- Yabu.transaction.commit - Commit a transaction
- SYNTAX
-
void commit();
- DESCRIPTION
-
This method commits the changes made in a transaction. If a record affected
by the transaction is altered during the transaction, a conflict will
arise and an error is thrown.
- SEE ALSO
- Yabu.table->transaction and Yabu.transaction->rollback
- METHOD
- Yabu.transaction.rollback - Rollback a transaction
- SYNTAX
-
void rollback();
- DESCRIPTION
-
This method cancels a transaction. All changes made in the transaction
are lost.
- SEE ALSO
- Yabu.table->transaction and Yabu.transaction->commit