Skip to main content

Query database

Sophie avatar
Written by Sophie
Updated over a week ago

Definition and Usage

Execute a query to retrieve data from the specified database and store the results as a datatable. This command allows you to extract information from databases using SQL queries and save the retrieved data for further processing in your workflow.


Parameter Values

Input parameters

Parameter

Description

Required

Options / Notes

Database

Select a database connection

Yes

Must be a valid database connection previously configured in the environment

SQL query statement

Enter the SQL query to execute

Yes

Can be any valid SQL statement; use the SQL tools option for assistance

Timeout (s)

Set the maximum duration (in seconds) for the query to run

Yes

Default is 30 seconds; increase for complex queries

Error handling

Parameter Name

Description

Throw error & stop

When an error occurs, the action will trigger an error and stop the execution of the entire app.

Retry command

If an error occurs, the action will retry the command in an attempt to resolve the issue and continue the process.

Ignore error & continue

When an error occurs, the action will be ignored, and the workflow will continue without interruption.

Variables produced

This action produces a datatable variable that contains the query results. The output is stored in the variable specified in the "Store result into" field.


Using Variables in Conditions

You can use variables in the SQL query statement by inserting them with the {variable} syntax. This allows you to create dynamic queries based on previously defined variables. For example, you could use a variable to filter results: SELECT * FROM customers WHERE region = '{customerRegion}'.


Notes

  • Ensure that the database connection is properly configured before executing this command.

  • The SQL query must be compatible with the selected database type.

  • Consider query performance and timeout settings when retrieving large datasets.

  • For complex queries, use the SQL tools option to help build and validate your query.

  • The output datatable structure will match the columns returned by your SQL query.

Did this answer your question?