Nested Tables in the Selection Fields List
A field in the selection list can refer to a nested table of query data sources. In this case, the field of query result will be of QueryResult type, i.e. contain a nested query result generated based on the nested source table.
By default, all fields of the nested table (data source) are included in the nested result. You can explicitly define a group of fields which must be included in the nested query result. The group of nested result fields is described in compliance with the following rule:
<Field group> | |
| | |
( <List of nested fields> ) | * |
| | |
<Nested field>[, <Nested field>[, …]] |
| | |
<Expression> [[AS] <Field Alias>] |
<List of nested fields> consists of a single or multiple comma separated items. If the list consists of one item, it does not need to be enclosed in parentheses.
Instead of listing nested fields, you can use an asterisk * which means that the nested query result should contain all the fields available in the nested table.
<Nested field> can represent some expression. In the simplest situation <Expression> is a link to a field in a nested table.
Every nested field can have an alias. <Field alias> can later be used for more convenient linking to this field (same as aliases of the selection list fields).
You can assign aliases to nested fields regardless of whether or not the alias of the nested table itself is specified.
Example:
// Consignment note specifications (the document, assortment and quantity)
// must be added to the report.Select
Document.ExpInvoice.Reference,
Document.ExpInvoice.Contents.(Nomenclature As Product, Count)
Query result:
Reference
Content
Invoice 00007 dated February 25, 2002 21:03:21
Product
Count
Women's jeans
4
Invoice 00006 dated February 25, 2002 0:00:00
Product
Count
Women's jeans
5
Invoice 00005 dated March 01, 2002 20:58:28
Product
Count
Women's jeans
1
Invoice 00004 dated March 01, 2002 20:50:40
Product
Count
Women's jeans
1
Invoice 00003 dated February 23, 2002 0:00:00
Product
Count
"Aquarium" bathroom
5
"Lilia" sink
8
"Ultra" mixer
10
Note that the "Content" field of the query result appears as a nested table, having the fields "Products" and "Count".
Example:
// All tabular section fields of an invoice must be added to the report.
Select
Document.ExpInvoice.Reference,
Document.ExpInvoice.Contents.*