Database transactions
A transaction is a group of database actions that are performed together. Either all the actions succeed together or they all fail together. When a group of database actions is made permanent, it is called committing a transaction. Rolling back a transaction cancels all of the actions of a non-committed transaction.
Explicit transaction control is available for any set of actions using the beginTransaction, commitTransaction, and rollbackTransaction methods. If transactions are not controlled explicitly, the runtime engine uses the underlying database's autocommit feature to treat each database modification as a separate transaction. Each statement is either committed or rolled back immediately, based on the success or failure of the individual statement. Explicitly managing transactions overrides this default behavior.
NOTE: When making changes to a database, it is recommended that explicit transaction control be used. If not, the database may report errors. However, even if errors are not specifically reported, data integrity cannot be guaranteed unless explicit transactions are used. In addition, any time a Cursors object is used to update a database, it is also recommended that explicit transactions be used to ensure the consistency of the data.
For the database object, the scope of a transaction is limited to lifetime of the connection. If the database object is disconnected before calling commitTransaction or rollbackTransaction method, then the transaction is automatically rolled back.
Database rollbackTransaction()