Database Query

 

Constructs and optionally runs an SQL query on a database table.

 

To use this action cell, you should be familiar with basic database terminology and SQL queries. To operate on information stored in a storm DATA MANAGEMENT table, use the DATA MANAGEMENT action cell instead.

Properties

Database Query Section

Bind Parameter Variables Section

Bind Result Variables Section

Database Query Section

Option

Description

Query Statement

Either create a new query statement by clicking  or use an existing statement. This is used to reference the query in a Fetch Query Result action cell if you are using a SELECT statement to retrieve information from a table into your script.

Note: this is useful if, for example, your script has separate routes to the same Execute Query action cell, where the different routes require the query to be run with different parameters or to return different values.

Select Data Source

Use this to select the data source identifier for the database containing the table against which the query will be run.

Query String

Enter an SQL query string, either by typing in the query here or using a string variable in which the query has been predefined. Standard SQL syntax is used. For example,

SELECT name, result, comments FROM customer  WHERE postcode = ‘SL6’

where name, result, comments and postcode are the names of columns in the table customer.

The values in the columns name, result and comments are to be returned to the FLOW script.

You may use ? characters in a query statement to act as placeholders for values you are binding to your FLOW script but you cannot use them for specifying table and column names. For example, the query statement:

SELECT name, results, comments FROM customer WHERE postcode = ‘?

is valid, but SELECT ?, ?, FROM customer WHERE postcode = ‘?’ is not.

You must specify variables in the Query Parameter list in the order in which they will be used to replace the ? placeholders in the query statement (see below).

Execute Query

Select this to execute the query. Alternatively, leave this clear and execute the query later in the script using the Execute Query action cell.

If the query is run, the results and the number of rows found are stored in memory and also to variables configured in the 'Query Result' list of this action cell (see below).

The results held in memory can be accessed by the Fetch Query Result action cell.

Result Rows

(Optional) Enter an integer variable to hold the number of result rows returned by the query if it is executed.

Bind Parameter Variables Section

Use this section to build a list of parameters for providing information to the query. If your query contains ? placeholders, these must in the same order as those in the query statement.

Option

Description

Query Parameter

Enter a values in the field above the list (as a literal value preceded by=, or a variable of the correct type), and then click ADD.

Bind Result Variables Section

Use this section to build a list of result variables for storing information returned by the query if it is executed by the action cell.

Option

Description

Query Result

Enter a variable of the correct type in the field above the list and then click ADD.

Exit Points

Exit Point

Description

Complete

This is taken if the query has been created successfully (and executed, where relevant).

Error

This is taken if the query has not been created successfully (or executed, where relevant).