ENFORM Reference Manual

Review of Rules for the LINK OPTIONAL Statement
LINKS and the LINK OPTIONAL Statement Rules
058057 Tandem Computers Incorporated C–9
The following query specifications, which attempt to generate a “double” exception
report, violate rule 2:
OPEN employee, region, branch;
LINK employee TO OPTIONAL region VIA regnum;
LINK employee TO OPTIONAL branch VIA branchnum;
LIST empname, employee.regnum, employee.branchnum
WHERE employee.regnum <> region.regnum OR
employee.branchnum <> branch.branchnum;
A sketch of these links appears as follows:
regionemployee
branch
The links within this query are illegal because both region and branch appear on the
right side of more than one LINK OPTIONAL statement. The WHERE clause
establishes three two-directional links between employee, region, and branch. Although
the LINK OPTIONAL statements cancel two of the three two-directional links (the link
between region and employee and the link between branch and employee), the link
between region and branch still exists. This link causes both region and branch to appear
more than once on the right side of a LINK OPTIONAL statement.
The following query specifications violate rule 2:
LINK employee TO OPTIONAL order VIA regnum;
LINK employee.empnum TO OPTIONAL order.salesman;
LIST empname, ordernum;
A sketch of these links appears as follows:
orderemployee
These specifications attempt to optionally link employee to order via two different
linking fields. Even though different linking fields are specified, order still appears on
the right side of two LINK OPTIONAL statements.