Execute Non Query
AutomatR.MSSQLDataBase.Database.ExecuteNonQuery
The "Execute Non Query" activity in AutomatR for SQL Server databases allows you to execute a non-query SQL statement, such as an INSERT, UPDATE, or DELETE statement, on a specified database. This activity is useful for making changes to the data in the database.
Properties
Name | Description |
---|---|
Input | |
Connection | Provide a SQL connection variable that will be used to establish a database connection. |
Command Text | Provide a SQL query in string format. This represents the non-query SQL statement to be executed (e.g., INSERT, UPDATE, DELETE). |
Misc | |
DisplayName | Provides 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 | |
Command Timeout | Provide the amount of time (in milliseconds) to wait for the SQL command to run before throwing an error. If not specified, the default timeout is set to 60 seconds. |
Delay | Specifies the amount of time (in seconds) to wait before executing the "Execute Non Query" 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. |
Output | |
Result | Outputs the result of the execution of the SQL command in an Int32 variable. The Int32 variable represents the result, typically indicating the number of rows affected by the SQL statement. This can be used for further processing or validation in the workflow. |
How to use:
- Drag and drop the "Execute Non Query" activity onto the workflow.
- Configure the properties by specifying the SQL connection variable, the SQL query (non-query statement), and optionally, the command timeout.
- Optionally, configure the delay for synchronization purposes.
- Execute the workflow to execute the specified non-query SQL statement on the database.
Example: Consider an example where the "Execute Non Query" activity is used to insert data into a SQL Server table:
Execute Non Query:
Connection: SqlConnectionVariable
Command Text: "INSERT INTO Employees (FirstName, LastName) VALUES ('John', 'Doe')"
Command Timeout: 5000
Result: RowsAffected
In this example, the activity executes the SQL INSERT statement to add a new record with the first name "John" and last name "Doe" into the "Employees" table. The number of affected rows is stored in the Int32 variable "RowsAffected" for further handling in the workflow.