queryToFile Step

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

Last published at: October 21st, 2024

Description:

This step executes a SQL query against the selected database and returns the results in a file in XLSX or CSV formats.

 

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 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 the “queryToFile” step to configure its “Advanced” properties. If necessary, provide a different DB name (other than FlowWright). By default, the step connects to the FlowWright database. 

 

  • The “Logging” setting configuration is necessary for documentation and also measures 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 instance, and execute. Render the process instance. Click on the process step to view its properties. The step should generate a 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 match the columns specified in the SQL query regarding the text Pascal case.  

 

 

Definition Sample:

You may download the sample definition(s) from the link here and later import it (drag-drop) to your FlowWright Process Definition (XML file) or Form Definition (HTML file) page.

NOTE: Please verify and complete the process steps for any missing configurations, such as file path references and database connections after import. Then, save the definition to confirm the changes.

Click here to download the sample file.