Template syntax | Data Fields

<< Click to display table of contents >>

Template syntax | Data Fields

See the topic about fields in templates for a general description of the syntax.


<data field> ::= [']<full data field name>['][ <field type>][ "<format>"]

<full data field name> ::= [<query processor>]<field name>

Full data field name may be enclosed in single quotes. These single quotes are necessary if <query processor> or <field name> contain space characters.

<query processor> ::= <name>: | : | ^+:

<field name> is a name of a field in a table generated by the rule.

Field names are case insensitive.

<field type> – see data field types section below.

<format> – see data field format strings section below.

About data fields

Data fields allow retrieving values returned by query processors. A query processor may be created to process the following data queries:

root data query

table row generation rule's data query

table cell's data query

Query() function in expressions

A query processor is referred in <query processor>.

If it is omitted, the results of the current (most deeply nested) query processor are used.

If only ':' is included, the results of the root query processor are used (the root query processor is a query processor created for root data query; if this data query is not assigned, there is no root query processor).

If an identifier <name> is included, it must be equal to name of table row generation rule, or a name of name of report table cell; a query processor associated with the referred object is used.

Special values:

'^' the parent query processor

'^^' the parent of the parent query processor

and so on


Data field types

A report generator supports the following types of fields:


integer value

floating point value

boolean (logical)

date, time, date and time

memo (a text document in ANSI or Unicode)

RTF document (normal RTF and RTF converted to a Unicode string)

HTML document

DocX document

Markdown document

RVF document

image (bitmap, icon, metafile, jpeg, gif, png, tiff, svg, if graphic classes for these formats are available).

additional field types implemented by programmers

If not specified, a format returned by TRVReportQueryProcessor.GetFieldType is used.

You can override the field type by specifying <field type>, read the topic about specifying data field types.

Data field format strings

Read the topic about format strings.


A data field can be used:

to insert its value in a template text;

to insert a text representation of its value in a string (such as a data query or a hyperlink target)

as a parameter of If, IfDef, IfNDef commands.

Note: if the field value is empty (NULL), it is not inserted in template text or strings.


These examples use SQL-based data queries.

Example 1: basic example

Let a cell's data query = 'SELECT first_name, last_name FROM persons'.

Let a data processor returns two records: ('John', 'Smith') and ('Mary', 'Black').

The cell contains:

{first_name} {last_name}

It produces:

John Smith
Mary Black

Example 2: master-detail

Let we have two database tables: master_table and detail_table.

Let there is report table having a row generation rule with the data query = 'SELECT master_id from master_table'.

Let this table has a cell (in a row affected by this rule) having the data query = 'SELECT * from detail_table WHERE master_id={master_id}'

As a result, we have a master-detail report.

Example 3

Let we have three database tables: sellers, products, sales. The "sales" table contains fields: seller_id, product_id, quantity, date (so it establish "N to N" relation between sellers and products).

Let there is table having a row generation rule with the data query = 'SELECT seller_id from sales', name = 'sellers_rule'.

It has a nested table, having a row generation rule with the data query = 'SELECT product_id from products', name = 'products_rule'.

In its order, it has a nested table, having a row generation rule with the data query = 'SELECT quantity, date WHERE seller_id={sellers_rule:seller_id} AND product_id={products_rule:product_id}'.

As a result, we have a report of sales grouped first by products, then by sellers.

Note: since, for the third table, 'products_rule' is the most recent rule, we could omit 'products_rule:' in '{products_rule:product_id}'.