Enform Plus Reference Manual
Statements
Enform Plus Reference Manual—422684-001
4-27
LINK OPTIONAL Statement Considerations
This statement causes Enform Plus to build:
•
A logical record description that consists of fields from both employee and branch.
•
One logical record for each matching employee and branch record. (Each logical
record contains field values from both records.)
•
One logical record for each employee record for which there is not a corresponding
branch record. Enform Plus builds this logical record by supplying blanks for the
fields in the logical record that correspond to the branch record description.
Because of the way that Enform Plus builds the logical records for this type of link, the
order in which you enter the record description names is important. For example:
LINK employee TO OPTIONAL branch VIA branchnum;
is not the same as:
LINK branch TO OPTIONAL employee VIA branchnum;
The first LINK OPTIONAL statement preserves the information in the employee
records; the second preserves the information in the branch records.
Rules for Using LINK OPTIONAL Statements
When you include LINK OPTIONAL statements in your query specifications, Enform
Plus requires you to adhere to certain rules for all of the links that affect your query.
These rules exist to eliminate the possibility of ambiguous links and to eliminate links
that are not supported by the current query processor.
Enform Plus uses these rules to determine whether your query specifications contain
legal links. (Unless otherwise stated, the word link applies to a link established by a
WHERE clause, a LINK statement, or a LINK OPTIONAL statement.) These rules are:
•
A record description on the right side of a LINK OPTIONAL statement must not be
linked back to the record description on the left side of the same LINK OPTIONAL
statement.
•
A given record description must not appear on the right side of more than one LINK
OPTIONAL statement. A record description appears on the right side of more than
one LINK OPTIONAL statement when you:
°
Specify the same record description on the right side of two or more LINK
OPTIONAL statements.
°
Specify a link (either with a LINK statement or a WHERE clause) between two
record descriptions, both of which appear on the right side of a LINK
OPTIONAL statement.
Note. If you specify a LINK OPTIONAL statement for record descriptions that are associated
with data files containing variable-length records, the linking field must be present in all of the
records from both data files. If the linking field is not present, a sort operation might fail.