Query Tag - Prefetch Data


To save the results of a query for use in an Autotag template, in order to prevent unnecessary duplicate database queries.

Background Information

In the case of large databases, queries often eat system resources on both the database server, and the client who then has to handle the query results. The purpose of the query tag is to reduce this problem by eliminating duplicate queries.


Inserting a Tag


1. Load the Sample MSSQL Datasource

Load the MSSQL datasource by clicking the bottom half of the "Data Sources" button, and selecting MSSQL. If there is no MSSQL option in the drop down menu, you may select another datasource, or follow the instructions in the "Creating a SQL datasource" tutorial.

Show Me How!

2. Insert a Query Tag

Insert a Query Tag. It will not appear on the final report, however its location does affect what tags are able to access the data queried. It should appear before any tags that need to use that data.

Show Me How!

3. Select Employees Table

We are going to query the entire Employees table--this way we can access any of the data in the Employees table and the database will only be queried once. Select the Employees table as you would normally select data for other tags.

Also, name the tag "[Query Employees]" and then set it's variable to "employees." In tags following the Query tag, the data queried is access by looking under the variable "employees."

Show Me How!

4. Insert an Out Tag

Insert an out tag and then look in the Data tree. At the top is the "employees" variable which contains the data queried earlier. Under that variable, find and select First Name.

Show Me How!

5. Evaluate the Tag

Evaluate the tag to see the results. This is to verify that the query retrieve the data correctly.

Show Me How!

Quiz Yourself!

What are Query tags useful for?
Query tags just help me see what's going on in my document while I'm designing it.
Query tags help me reduce the system resources used in document generation by saving query results so I only query my server once.
Query tags are required in document generation. I have to query data before I can use it because the out tag doesn't do that for me.


You have completed this tutorial. We recommend taking a look at the Inserting Pre-Made Tags from the Data Bin tutorial next!