xHarbour Reference Documentation > Command Reference |
Synchronizes the record pointers in one or more work areas.
SET RELATION TO [<expression1>|<nRecord1> INTO <cAlias1> [SCOPED]] ; [, [TO] <expressionN>|<nRecordN> INTO <cAliasN> [SCOPED]] [ADDITIVE]
The record pointer in the child work area is synchronized using a SEEK operation. The value of <expression> is passed to SEEK.
When no argument is passed, all active relations in the current work area are cleared.
The SET RELATION command relates a parent work area with one or more child work areas. This causes the record pointer in a child work area to be synchronized with the record pointer in the parent work area.
Synchronization of the record pointer in a child work area is accomplished either relative via an index, or absolute via a record number.
Relative synchronization
This requires a controlling index in the child work area. Each time the record pointer moves in the parent work area, the value of <expression> is SEEKed in the child work area. As a consequence, the data type of <expression> must match the data type of the controlling index in the child work area.
Absolute synchronization
When the child work area has no controlling index, or when the type of the index expression is not numeric and the relation expression is numeric, the child work area is synchronized via GOTO <nRecord>.
Notes
The record pointer in the child work area is positioned on Lastrec()+1 when there is no match with the relation expression.
It is illegal to relate a parent work area directly or indirectly with itself.
The SET RELATION command does not support SOFTSEEK. It always acts as if SOFTSEEK is set to OFF.
When relating two work areas based on matching record numbers, use the Recno() function for the SET RELATION TO expression. Make sure that the child work area has no controlling index.
See also: | DbClearRelation(), DbRelation(), DbRSelect(), DbSetRelation(), Found(), RecNo(), SET INDEX, SET ORDER, SET SOFTSEEK |
Category: | Database commands |
Source: | rdd\dbcmd.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example lists data from a customer and an invoice database PROCEDURE Main USE Customer ALIAS Cust USE Invoice ALIA Inv NEW INDEX ON CustNo TO Invoice01 SELECT Cust SET RELATION TO CustNo INTO Inv // Invoice data changes whith each SKIP in Customer database DO WHILE .NOT. Eof() ? Cust->LastName, Cust->FirstName, Inv->Total SKIP ENDDO CLOSE ALL RETURN
http://www.xHarbour.com