Skip to main content

Start Transaction

AutomatR.PostgreSQL.Database.StartTransaction

The "Start Transaction" activity in AutomatR for PostgreSQL databases allows you to initiate a transaction on a database. Transactions are crucial for ensuring the consistency and integrity of the data, especially when multiple operations need to be executed as a single unit.

Properties

NameDescription
Input
ConnectionSpecifies a NpgsqlConnection variable used to establish a connection to the PostgreSQL database. This connection will be utilized for the duration of the transaction. NpgsqlConnection variables containing the required database connection.
Misc
Display NameProvides a customizable name for the activity displayed in the workflow. The display name enhances clarity and organization within the automation project. String variables containing the desired display name.
Optional
DelaySpecifies the amount of time (in seconds) to wait before executing the "Start Transaction" activity. This can be useful for handling synchronization issues. Integer variables containing the delay duration. Ex.: If the amount of time is 1000 milliseconds or 1 sec, i.e., 1.
BodySpecifies the sequence of activities that will be executed as part of the transaction. The activities defined in this sequence will be treated as part of the same database transaction.

How to use:

  1. Drag and drop the "Start Transaction" activity onto the workflow.
  2. Configure the properties by providing the NpgsqlConnection variable for establishing a connection to the PostgreSQL database.
  3. Optionally, configure the delay for the desired waiting time before starting the transaction.
  4. Define the sequence of activities that will be part of the transaction using the "Body" property.
  5. Execute the workflow to begin the transaction and execute the specified activities within the transaction scope.

Example: Consider an example where the "Start Transaction" activity is used to initiate a transaction before executing database operations:

Start Transaction:
Connection: postgresConnection
Delay: 2
Body:
- Execute SQL Query: "INSERT INTO table1 (column1, column2) VALUES ('value1', 'value2')"
- Execute SQL Query: "UPDATE table2 SET column1 = 'newvalue' WHERE column2 = 'somecondition'"
- ...

In this example, the activities defined within the "Body" property are executed as part of a single transaction. If any of the activities fail, the transaction will be rolled back, ensuring data integrity in the PostgreSQL database.

Note: Ensure that the "Start Transaction" activity is used in conjunction with the "Roll Back Transaction" and "Commit Transaction" activities to handle success and failure scenarios within the workflow. Additionally, the delay is optional and can be configured based on specific requirements for handling transactions.