Specify relationships between open tables
SET RELATION TO [<key> INTO <alias>[, <key INTO <alias>][ADDITIVE]]
SET RELATION ON | OFF | (<expL>)
The SET RELATION TO command defines a relationship between the currently selected table and one or more other tables. The target table of the relationship must be open prior to establishing relationships. The target table should be indexed on the <key expression> and that index should be the master index associated with the target table.
If the ADDITIVE keyword is specified, the specified relationship is added to the relationships already defined for the currently selected table. Cyclic relationships are invalid and checks are automatically made for these, and an error given if one exists. The SET RELATION TO command with no relationship specified cancels any current relationships.
When a workarea is closed, or a new table is opened in a workarea, the relationships are automatically canceled. The SET RELATION ON or OFF commands enable or disable the satisfying of relationships on a system wide basis. Whenever a record is read from the active table, the <key expression> is evaluated for each of the related tables, and the resulting key is searched for in their master index files. If the key is found, the corresponding record is read from the required table into its associated workarea. Relationships from that workarea to other workareas are then satisfied.
If a key is not found in the master index file of a related table, the record buffer in the associated workarea for that particular table, and any tables related to it, are initialized in the same way as the APPEND BLANK command operates.
select b use addresses index add_names select c use accounts index acc_names select a use patrons index events, dates, names set relation to name into addresses,; name into accounts set filter to accounts->balance>1000 list date, event, addresses->street, addresses->city, accounts->balance