Icon StartTransaction Method

procedure StartTransaction(const Tables: TEDBStringsArray;
      Timeout: Integer=-1)

procedure StartTransaction(const Tables: array of const;
      Timeout: Integer=-1)

Usage

Call the StartTransaction method to begin a new transaction. Before calling the StartTransaction method, an application should check the status of the InTransaction property. If the InTransaction property is True, indicating that a transaction is already in progress, a subsequent call to StartTransaction without first calling the Commit or Rollback methods to end the current transaction will raise an exception.

The Tables parameter allows you to specify a list of table names that should be included in the transaction. This is called a restricted transaction, since it usually involves only a subset of the tables in the database. If the Tables parameter is nil or has a length of 0, then the transaction will encompass the entire database. To make things easier in cases where an empty array is required, we have included the following pre-declared empty array in the edbtype unit:

EmptyEDBStringsArray

Just pass this variable name to the StartTransaction method whenever you wish to start a transaction on the entire database.

After the StartTransaction method is called, any row updates, insertions, and deletions that take place on tables that are part of the active transaction are buffered by ElevateDB until an application calls the Commit method to save the changes or the Rollback method is to cancel them.

The Timeout parameter indicates how long a transaction will wait, in milliseconds, to acquire the necessary lock(s) to start the transaction. The default value is -1, which will cause the transaction to wait up to several minutes before issuing a lock failure exception.

Information The transaction isolation level in ElevateDB is always serialized, meaning that ElevateDB will only allow one session at a time to have an active transaction on the same table or tables.
Image