User guide

Connecting Record Descriptions to Form New Relationships
Developing an ENFORM Query
3–20 058058 Tandem Computers Incorporated
Since employee is optionally linked to region, the logical record occurrences built for the
linked record descriptions contain all of the employee records. The WHERE clause tells
ENFORM that you are interested only in those logical record occurrences that do not
have data values in the fields that correspond to the region record descriptions. (Note
that the link established by the WHERE clause is not illegal because it references the
same record descriptions as those referenced in the LINK OPTIONAL statement.)
ENFORM, therefore, produces the following report:
EMPNAME REGNUM
------------------ ------
ALDEN SPROWLES 67
JOAN ZIMMERMAN 11
BOB CHAPIN 17
LIZ CHAMBERS 59
If you want to produce an exception report that lists all the employees with invalid
region numbers and invalid branch numbers, you could use LINK OPTIONAL
statements to link employee to both region and branch. In this case, you could use a
SUPPRESS clause to specify that the report is to contain only the names of those
employees who have invalid region or branch numbers. (You cannot use a WHERE
clause because such a clause would establish a link that violates the rules for the LINK
OPTIONAL statement.) The specifications for this query might appear as follows:
OPEN employee, branch, region;
LINK employee TO OPTIONAL region VIA regnum;
LINK employee.dept TO OPTIONAL branch.primkey;
LIST empname, employee.regnum, employee.branchnum
SUPPRESS WHERE employee.regnum = region.regnum
AND employee.dept = branch.primkey;
A sketch of these links appears as follows:
employee region
branch