SET RELATION

From Recital Documentation Wiki
Revision as of 09:41, 13 January 2010 by Yvonnemilne (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Purpose

Specify relationships between open tables


Syntax

SET RELATION TO [<key> INTO <alias>[, <key INTO <alias>][ADDITIVE]]

SET RELATION ON | OFF | (<expL>)


See Also

@...GET, ALIAS(), APPEND BLANK, CREATE, CREATE VIEW, DBF(), DBRSELECT(), INDEX, KEYMATCH(), LOOKUP(), MODIFY STRUCTURE, RLOOKUP(), SELECT, SET AUTOJOIN, SET FILTER, SET SKIP, SET ORDER, SET VIEW, SKIP, TARGET(), USE


Description

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 target table is not indexed, and SET AUTOJOIN is ON, then an index will be created automatically to satisfy the relationship. Use of the SET AUTOJOIN feature should be restricted to defining temporary relationships only, as a temporary index is created each time the relationship is established. Permanent relationships can be defined with the CREATE VIEW command, and established with the SET VIEW TO command.

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. Relationships can also be specified with @...GET commands, please see the @...GET command for details. It should be noted that the <key expression> can reference fields in any workarea by using the alias pointer notation ’->’ or ’.’.


Example

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


Products

Recital Server, Recital