Create file from SQL results

Use this step to fetch the SQL resultset to an XLS or CSV file.

Last published at: August 30th, 2023

queryToFile Step

Description:

This step executes a SQL query against the selected database and return the results in file.

Inputs

  • name - step name
  • connectionString – connection string to the database
  • sqlQuery – SQL query to execute
  • resultFileFormat – return results in selected file format
  • varGlobalFilePath - Specifies the file path for the output
  • changeDatabase - connect to different Database
 

 

Returns

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

 

Usage:

 

 

Example:

Let’s build and execute the “queryToFileDef” example.          

  • Create a new definition called “queryToFileDef” 
  • Select the definition and click the “design” button
  • Drag a “queryToFile” step from the toolbox
  • Connect the dots between the start and “queryToFile” step
  • Click on the “querytofile” step to configure its “Settings” properties. Provide a name to the step. Select the connection string from the drop down list. Provide a SQL Select query. Select the result type from the drop down list. Provide a variable/global to store the result. 
  • Click on the “querytofile” step to configure its “Advanced” properties. Provide a different DB name (other than FlowWright) if required and by default, the step connects to the FlowWright database. 
  • The “Logging” setting configuration is necessary for documentation and also measure the workflow progress and the percent complete. This is achieved 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 to view the properties. The step should create file from SQL results. 
  • Render the process instance. Inspect the step variable/properties. Inspect the output result file. The column headers in the output excel file matches the columns specified in the SQL query with regards to text pascal case.