Executes a SQL statement

Use this step to execute a SQL statement or stored procedure.

Last published at: August 30th, 2023

executeSQL Step

Description:

This step executes a SQL statement against the selected database, if an select statement, returns an XML record set.

 

Inputs

  • singleResult – Returns a single result
  • connectionString – connection string to the database
  • changeDatabase - Connect to a different Database
  • sqlStatement – SQL statement to execute
  • variableName – variable/global to store the value from the SQL statement
  • resultFormat – Result Format (XML/JSON)
  • Connect to a different database - Connect to different database on the same connection string path
  • Return a single result - Select YES for 1 row & 1 column expected result
  • SQLParameters - SQL parameter and values
  • CommandTimeOut – Command timeout value (default 30 secs)
 

 

Returns

  • True – SQL statement executed successfully
  • False – SQL statement failed to execute
 

 

Usage:

 

Example:

Let’s build and execute the executeSQLDef example.                             

  • Create a new definition called “executeSQLDef”
  • Select the definition and click the “design” button
  • Drag an “executeSQL” step to the canvas
  • Connect the dots between the start and “executeSQL” step
  • Define a variable/global to store the result after execution
  • Click on the "executeSQL" step to configure its "Settings" properties. Provide a name to the step. Select the connection string from the list. Provide the SQL SELECT statement. The statement in this example is configured with a parameter (?) and the value is supplied through a variable reference. Select result format as XML or JSON. 
  • Click on the "executeSQL" step to configure its "Advanced" properties. Provide a variable/global to store the result. Select the result to return single row or column (if necessary). Select SQL command time out value in seconds. Define SQL parameter and values.
  • Define SQL parameter and values. Provide parameter name and values to be used in run time. 
  • The “Logging” setting configuration is necessary for documentation and also measure the workflow progress and the percent complete. This is acheived by configuring the step state and percent fields individually as shown in the images below. Configure the “Logging” using the following properties.
  • Save the process definition, create a new process instance and execute. 
  • Render the process instance. Click on the process step. The step should should execute the SQL query in selected database server and returns result in JSON or XML based on the result format.
  • To execute a stored procedure, Click on the "executeSQL" step to configure its "Settings" properties. Provide a name to the step. Select the connection string from the list. Provide the stored procedure info as shown below - with question marks identified as parameters. The statement in this example is configured with a parameter (?) and the value is supplied through a variable reference. Select result format as XML or JSON. 
  • Define SQL parameter and values. Provide parameter name and values to be used in run time. 
  • To connect to different database, mention the DB name which is accessible on the same connection string.