Query Processing |
![]() ![]() ![]() |
QM verbs that select records from files or produce reports are handled by the query processor. All query processor verbs follow a common format.
The query processor verbs are
The General Form of a Query Processor Verb
All query processor verbs follow the same general format though not all parts are applicable to all verbs. The components of the command may be in any order except that the file name must immediately follow the verb and the order may be significant in repeated instances of an element.
verb {DICT} file.name {USING {DICT} file.name} {field.name {field.qualifier} ...} {sort.clause } {record.id...} {FROM select.list.no} {TO select.list.no}
where
Phrases defined in the VOC or the dictionary may be included at any point in a query processor command and will be expanded at that position in the command line.
Literal values used in selection or sort clauses do not need to be enclosed in quotes unless they correspond to names defined in either the VOC or the file's dictionary or if the contain spaces, commas or quotes. Use of quotes is recommended to prevent incorrect interpretation of commands.
The $QUERY.DEFAULTS Record
The default actions of the query processor LIST, SORT, LIST.LABEL and SORT.LABEL commands can be controlled by adding an X-type record to the VOC file or to the dictionary of the file referenced by the query command. Field 2 of this record contains query processor command line elements that will be inserted into the command after the file name but before any further command line options. The options may extend over multiple lines by use of an underscore as the last character of the line to indicate that a continuation line is present. The lines are merged together with the underscore replaced by a single space.
The query processor checks first for this optional record in the dictionary of the file. If it is not found, it then looks in the VOC. It is therefore possible to use a VOC record to set account level defaults which can be overridden by an alternative record in individual dictionaries. A $QUERY.DEFAULTS record in the dictionary with a type code of X but no further content will effectively disable use of the VOC $QUERY.DEFAULTS record whilst not applying any defaults of its own.
Links
Dictionary L-type records can be used to represent a relationship between two files without the need to include a separate I-type TRANS() expression for each field.
In a query command, a link is used by specifying a field name that is constructed from the link name and the name of a field in the linked file, separated by a percent sign (%).
For example, consider a library application where the BOOKS file representing a physical copy of a book uses a composite key constructed from the id of a record in the TITLES file and the copy number, separated by a hyphen. A link record could be placed in the dictionary of the BOOKS file:
TITLES 1: L 2: @ID['-', 1, 1] 3: TITLES
A query against the BOOKS file may then refer to fields from the TITLES file as, for example, TITLES%AUTHOR. The linked field (AUTHOR in this example) must be a D or I-type item.
To allow use of field names that contain % characters, the query processor only interprets a field name containing a % character as a link if there is no dictionary or VOC item corresponding to the entire name. |