BeginTrans Method

Begins a transaction.

Applies to objects: Connection, Database, Workspace.

Syntax

[[Let] RetVal = ] object.BeginTrans([IsolationLevel])

The BeginTrans method syntax has these parts:

Part Description
object Required. A reference to an instance of the object.
RetVal Optional. A Boolean type variable that indicates whether the transaction could be started.
IsolationLevel Optional. A Long type variable, indicating the isolation level of the transaction.

Remarks

The BeginTrans method switches the transaction mechanism from automatical to manual execution mode. In the automatical mode it's not possible to organize all database changes into one block and is not possible to cancel transactions. In the manual execution mode all operations following BeginTrans are treated as a single block, executed with the CommitTrans, and cancelation of a transaction is handles by the RollbackTrans function.

The Connection and Database allow to define the transaction support and available transaction isolation levels for the database connection described by them with the help of the Transactions and IsolationLevels methods. The BeginTrans method, that belongs to these objects, can take the IsolationLevel parameter, that sets the isolation level for the transaction. This parameter can be omitted - then the default isolation level for the database will be accepted.

The Workspace object provides general control over transactions. On calling its method BeginTrans, the BeginTrans of all Connection and Database objects, that belong to it and support transactions, will be called without parameters. The BeginTrans method of the Workspace object returns no result.

After calling the CommitTrans and RollbackTrans functions automatical transaction execution mode is restored. To form the next transaction, the BeginTrans method must be called again.

If none of these functions is called, transaction will be committed by the CommitTrans function on destroying or closing the object, controlling this transaction (Connection, Database, Workspace).

Example

.......

 

See Also

Connection Object, Database Object, Workspace Object, Transactions Property, IsolationLevels Property, CommitTrans Method, RollbackTrans Method.