Query Tag Tutorial

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}.

  1. Selecting the Query Tag, this can be done through the Tag Editor. For this example we will be using the Northwind.xml data.
  2. Once the Query Tag is selected make sure to create a var name to go with it. Next select the Select tab on the top of the Tag Editor. Drag your variable into the select box and evaluate to ensure the process was done correctly.
    Once evaluated by default the viewer will show the first employee information or the first data set. To change which data set you want your query to look at proceed to the wizard. 
    The wizard will take you to a screen that looks like the If Tag window.For this example we want to choose the employee with the Employee ID equal to number 5. Click ok and the window will close. The Tag Editor viewer will now show the employee with Employee ID equal to 5’s information.
  3. Create Out tags particular for the Query Tag. Now let’s say we want to have our report have the first name, last name and date of birth of the specific employee.
    Type out your outputs:
    First Name:
    Last Name:
    Date of Birth:
     
    Place out tags next to your outputs,
    First Name: <out>
    Last Name: <out>
    Date of Birth: <out>
    1. Select the first out tag next to First Name, and go to the Data tree under the Blueprint tab. There is now a query family of nodes in the Data tree.
    2. Select the First Name under the query family of nodes. This out tag will now only output the first name of the Employee ID equal to 5.
    3. Continue this process for Last Name and Date of Birth. Make sure to make the Date of Birth tag a Date tag found under Type.
      As a result your tags should resemble below:
      <Employees>
      First Name:<FirstName>
      Last Name:<LastName>
      Date of Birth:<BirthDate>
       
      Save and run your report and the end result will resemble this, information only on employee with Employee ID equal to 5.
       
      First Name: Steven
      Last Name: Buchanan
      Date of Birth: 04-Mar-55