BeginTransaction

The BeginTransaction function serves as a wrapper for multiple SQL statements.

This function creates a Transaction object in its execution path that can be used by the ExecuteSQL or ExecuteStoredProcedure functions.

The transaction is committed automatically after all the functions in the execution path finished executing.

If one of the SQL statements returns an error or fails to execute, all SQL statements inside the transaction are rolled back.

Properties

Connection type

The type of database driver to use to connect to the database.

The supported driver types are:

  • SQL Server

  • Oracle

  • OLE DB

  • ODBC

Connection string

The connection string that specifies how to connect to the database.

Isolation level

The isolation level for the transaction. learn more

The available options depend on the Connection type that was selected.

Isolation level Connection type
Chaos OLE DB
Read committed OLE DB, SQL Server, Oracle, OLE DB, ODBC
Read uncommitted SQL Server, OLE DB, ODBC
Repeatable read SQL Server, OLE DB, ODBC
Serializable SQL Server, Oracle, OLE DB, ODBC


Example

Suppose you have a sales order containing several line items that must be added to the database.

Using ExecuteSQL without BeginTransaction would create a new database connection for each item written to the database. However, by using BeginTransaction, we can add everything in the same transaction.

If something should go wrong during the creation of the order, the entire transaction would be rolled back, guaranteeing that we never end up having incomplete orders in the database. Adding many records using the same transaction will also execute a lot faster.

Steps:

  1. Add a BeginTransaction function to your Solution.
  2. Set up the database connection for the BeginTransaction function.
  3. Add your ExecuteSQL functions to your work flow.
  4. For each ExecuteSQL, set the Connection type property to 'Use transaction'.
  5. Set the Transaction property (only displayed when Connection type property is 'Use transaction') to 'BeginTransaction.Transaction'.


BeginTransaction


Wikipedia: Database transaction

Wikipedia: Isolation (database systems)