A query defines what data is extracted from the data source
and takes the form of a path in the data source schema. You can assign
a query to a template element to define the data context for that
element and its children.
Procedure
- Assign queries.
- In Document Studio, open the Data Source
Schema view.
- Add elements to the template.
- Drag the queries from the Data Source Schema view
into the elements.
A query is assigned to a template element, you can use the attributes
of the query type, the element dragged from the Data Source
Schema view, anywhere in the template element and its
child elements.
- Set a limit to the query element.
Note: You
can process a subset of template elements by setting a limit to the
query elements.
- In Document Studio, select the template element that
contains the query.
- In the Properties view, select
the Data tab.
- For the Limit property, enter
the number of objects from the data source to be used in the respective
query. A value of 0 (zero) represents no limit
set for the query.
- Assign recurrent properties to the queries. You
use data recursion to extract all of the child requirements from a
main source requirement in a schema.
- Select the element that contains the query.
- In the Properties view, for the Recursive
Level property, enter how many levels deep the query is.
- For the Recursive Segments property,
enter how many times the segments repeat in the query.
See the example below about recursive levels and recursive
segments.
- Save your changes.
Results
When you apply a query to an element, there
are three visual indicators that display in blue by default in the
template content editor:
- The data source schema name
- The context displayed with a dollar sign ($)
- The query name
Tip: When clearing information from queries, Clear
queries and Clear all work differently. Clear
queries is only available when you select an element that
has a query. Clear all removes all of the queries,
attributes, filters, sorts, and conditions on the element you have
selected and its child elements, if they also have queries or attributes
assigned to them. Master pages, styles, and formatting properties
are not removed.
Example: Recursive level and recursive segments
For
each parent query, you can extract all of the child requirements,
and for each child requirement, extract its child requirements without
adding each query to your template.
Instead of adding each
of these following queries:
- [$1] Query1/Query2/Query3 to
extract the Query3.
- [$2] $1/Query4/Query5/Query6 to
extract child requirements of each Query3.
- [$3] $2/Query4/Query5/Query6 to
extract child requirements of each child requirement of each Query3.
You can construct one query for these requirements automatically:
- Add the Query1/Query2/Query3/Query4/Query5/Query6 query
to an element.
- Add values to the Recursive Level and Recursive Segments properties:
- Run the report to test.
On running the report, these queries
are included:
If you find that the number entered for the
Recursive
Segments property is higher than the number of segments
that the query contains, you can use one of these two options to resolve
the issue:
- Select the element that has the Recursive Segments property
applied. In the Properties view, select the Data tab
and decrease the value for the recursive segments property.
- You can also redesign the query to start from a different parent
query. If your Recursive Segments value is
one segment too high, create a container element and add a query that
is one level higher than the parent query of the existing element.
Then move the existing element into the container element.
What to do next
Tip: You can search
for a list of queries and attributes by right-clicking an element
and selecting . The Search view opens
and a list of queries and attributes displays. You can double-click
a query or attribute in the results to edit its content.You can search for a list
of variable assignments, attributes, and queries used in an element
by right-clicking an element and selecting . The
Search view opens and a list displays. You can double-click an item
in the results to edit it.
You can locate a query or attribute in the Data Source
Schemas view from the element it is applied to by right-clicking an
element and selecting . The Data Source
Schema view opens and the query or attribute is highlighted.