DBCommitTrans Action

Commit the database transaction.

Use

These actions manage transaction processing within a DB Connection object as follows:

  • DBBeginTrans - Begins a new transaction.
  • DBCommitTrans - Saves any changes and ends the current transaction, then begins a new transaction.
  • DBRollbackTrans - Cancels any changes made during the current transaction and ends the transaction, then begins a new transaction.

Use these actions with a Connection object when you want to save or cancel a series of changes made to the source data as a single unit. For example, to transfer money between accounts, you subtract an amount from one and add the same amount to the other. If either update fails, the accounts no longer balance. Making these changes within a transaction ensures that either all or none of the changes go through.

For providers that support nested transactions, calling the DBBeginTrans action within an open transaction starts a new, nested transaction. The TransactionLevel property of a Connection object indicates the level of nesting: a return value of "1" indicates you have opened a top-level transaction (that is, the transaction is not nested within another transaction), "2" indicates that you have opened a second-level transaction (a transaction nested within a top-level transaction), and so forth. Calling DBCommitTrans or DBRollbackTrans affects only the most recently opened transaction; you must close or roll back the current transaction before you can resolve any higher-level transactions.

The isolation level for the transaction is specified in the connection string that was used in the DBConnect action.

Parameters

Connection  -  (Required)

Specifies the name of the Connection object for which the transaction applies.

Additional Notes

For DDM data sources, journaling for the database file must be set up on the server in order for these actions to succeed. If journaling has not been set up for the database file, then no error will occur but the actions will have no effect. For ADO data sources, support for these actions depends upon the OLE DB provider and may not be available in some Recordsets.

When a transaction is committed or rolled back, a new transaction may be started immediately after the current one ends. For DDM data sources, a new transaction is always started. For ADO data sources this behaviour depends upon the OLE DB provider. The advanced view in the Connection tab of the Database Description dialog shows the behaviour for a particular Recordset. If Retaining Abort is set to True, then a new transaction is started immediately after a transaction is rolled back. If Retaining Commit is set to True, then a new transaction is started immediately after a transaction is committed. Otherwise, no new transaction is created.

After a transaction ends, the full functionality of a Recordset may be preserved, or the Recordordset may become unusable. For DDM data sources, the recordset is always usable after committing or rolling back a transaction. For ADO data sources this behaviour depends upon the OLE DB provider. The advanced view in the Recordset tab of the Database Description dialog shows the behaviour for a particular Recordset. If Preserve on Abort is set to True, then the Recordset is usable after rolling back a transaction. If Preserve on Commit is set to True, then the Recordset is usable after committing a transaction. Otherwise, the Recordset is unusable after a transaction ends and should be closed.

See Also

DBConnect Action | DBDisconnect Action | DBOpen Action | DBClose Action | DBFind Action | DBMove Action | DBAddNew Action | DBBeginTrans Action | DBCancelUpdate Action | DBCommitTrans Action | DBDelete Action | DBRollbackTrans Action | DBSeek Action | DBUpdate Action