Difference between revisions of "SET RELATION"
Yvonnemilne (Talk | contribs) |
Yvonnemilne (Talk | contribs) |
||
(8 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==Purpose== | ==Purpose== | ||
Specify relationships between open tables | Specify relationships between open tables | ||
Line 11: | Line 4: | ||
==Syntax== | ==Syntax== | ||
− | SET RELATION TO [<key> INTO <alias>[,<key INTO <alias>][ADDITIVE]] | + | SET RELATION TO [<key> INTO <alias>[, <key INTO <alias>][ADDITIVE]] |
SET RELATION ON | OFF | (<expL>) | SET RELATION ON | OFF | (<expL>) | ||
Line 17: | Line 10: | ||
==See Also== | ==See Also== | ||
− | [[CREATE VIEW]], [[SET FILTER]], [[SET VIEW]] | + | [[@...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]] |
Line 23: | Line 16: | ||
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. | 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 | + | 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. | 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. | ||
Line 39: | Line 32: | ||
use patrons index events, dates, names | use patrons index events, dates, names | ||
set relation to name into addresses,; | set relation to name into addresses,; | ||
− | name into accounts | + | name into accounts |
set filter to accounts->balance>1000 | set filter to accounts->balance>1000 | ||
− | list date, event, | + | list date, event, addresses->street, addresses->city, accounts->balance |
− | addresses->street, | + | </code> |
− | addresses->city, | + | |
− | accounts->balance</code> | + | |
==Products== | ==Products== | ||
− | Recital | + | Recital Server, Recital |
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:Commands]] | [[Category:Commands]] | ||
[[Category:Set_Commands|RELATION]] | [[Category:Set_Commands|RELATION]] | ||
+ | [[Category:Table Basics]] | ||
+ | [[Category:Table Basics Set Commands]] | ||
+ | [[Category:Data Commands]] |
Latest revision as of 09:41, 13 January 2010
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