Many external databases support transactions (see property ExternalDatabase::SupportTransactions). A transaction is a group of database operations combined into a logical unit of work that is either wholly committed or rolled back. A transaction has the following properties:
Atomicity ensures that all changes made under a specific transaction are committed or that all are aborted and rolled back to their previous state.
Consistency means that all changes made under a specific transaction should not result in database incorrect state or destroy database structure.
Isolation protects concurrent transactions from reading partial and uncommitted results, which might create inconsistencies in the application state.
Durability means that committed changes survive physical failures and allows you to recover the durable state after disk failures.
The GIS kernel provides the following modes of transaction end for external databases that support transactions:
Ending a transaction after every record modification (the property ExternalDatabase::CommitThreshold returns 0).
Ending a transaction after modification of a specified number of records (the property ExternalDatabase::CommitThreshold returns value greater than 0). The specified number of inserts, deletes and updates are executed as a separate transaction.
Ending a transaction when closing an external database (the property ExternalDatabase::CommitThreshold returns value less than 0). The transaction begins when the database opens. All changes are then performed under a given transaction. The transaction ends when the database closes.
The following factors influence the choice of transaction end mode:
Performance. In some databases transactions are implemented so that all recordsets are closed when a transaction ends (see the property ExternalDatabase::PreserveRecordsetOnCommit). The GIS kernel recognizes when a recordset changes its state to passive and triggers the event Recordset::Deactivated. An application may change the recordset's state to active by the Recordset::Refresh method while handling this event. Therefore, if an external database changes recordsets' states to passive at transaction end and the mode of ending a transaction after every record modification (the property ExternalDatabase::CommitThreshold returns 0) is set, the performance is reduced essentially.
Concurrency. If records are locked when modified, a record remains locked until transaction end. If the mode of ending a transaction while closing an external database (the property ExternalDatabase::CommitThreshold returns value less than 0) is set and there are many modified records, the concurrency may reduce because other users will wait the end of transaction (i.e., the end of session).
Safety. If hardware failures or software failures occur while working with an external database, all changes made in the current transaction are usually lost. If the mode of ending a transaction while closing an external database (the property ExternalDatabase::CommitThreshold returns value less than 0) is set, all changes made to the external database during the session will be lost in case of failure.