Skip to main content
Windward

Query Tag Reference

Overview

Tag: query tag: <wr:query ... />

Designed primarily to be used with large SQL databases, query tags let you save the results of a query and then later refer to the data retrieved by that query without having to re-access the database. This saves resources, because you aren't making unnecessary calls to the database (which can eat up system resources.)

Use the query tag to retrieve the value of a specified data item (group) from your data source, storing the result in a newly created variable. The name of this variable can subsequently be used in other tags as a relative data reference, using ${name}.

 

Use the query tag to retrieve the value of a specified data item (node) from your data source, storing the result in a newly created variable. The name of this variable can subsequently be used in other tags as a relative data reference, using ${name}.

This tag provides the ability to use the equivalent of the C# use construct.

The purpose of this tag is to create a node that can be referenced by other tags. While it can be used in other ways under some of the data providers, its results are not guaranteed for any other use.

Attributes

  • select – required. Select the node (table) to equate with this variable.

  • var – required. Set this attribute to the name of the variable to equate with the selected node (data table). You may refer to this table in subsequent tags by using the ${name} construct, where name is the value you enter for this attribute. You may use letters, numbers and underscores (_), but the first character must not be a number. Spaces are not allowed. There is no length limit.

Once defined, the var variable can be used to refer to this table in other tags, using ${name}. You can refer to a specific data item in this table by using ${name.item}. If you are using a SQL data source, refer to the SQL usage section below.

XML Usage

<wr:query select="./name" var="name"/>

which evaluates the value as a node in the data and stores the result in var. If the select makes use of a var in a forEach tag, then this var is still good when the forEach loop is exited.

SQL Usage

<wr::query select="select * from PERSON where PERSON_ID = ${user.BILLING_ID}" var="person"/>

Selects all rows in the PERSON table where the PERSON_ID column has the value of ${user.BILLING_ID}. The ${user} comes from a previous query.

The var attribute can also be used as:

${var[1]}

${var.COLUMN}

${var.columnNames[1]}

For details, refer to the SQL Data Source section.

Note: For both query & set vars, if the name starts with an underscore like ${_item.column} then when placed in a select, it will be substituted in literally. For the normal case, the text will be adjusted if it has characters that need to be changed. In SQL a ‘ will be turned into ‘’ while in XPath it will become &apos;

Deleting a Query 

To delete a query, call this with a query that is a 0-length string:

<wr:query select="" var="name"/>

Once deleted, you may no longer reference the node (table) using ${name}.

The purpose of this tag is to create a node (table) that can be referenced by other tags — nothing is output. While it can be used in other ways under some of the data providers, its results are not guaranteed for any other use.

  • Was this article helpful?