Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What will this code do

Status
Not open for further replies.

tforr

Programmer
Aug 14, 2003
181
GB
Can anyone let me know what the following code does:

SET RELATION TO Dept + Employee INTO TRANS

Thanks in advance,

Tom
 
Tom,
It assumes that the current table is related through the combination of the two fields of (Dept + Employee) to the current index setting used by the previously opened table TRANS. Once completed, as you move through TRANS, it will effectively filter the current table to the record or records that match this indexed value.

Rick
 
Hi Tom:

SET RELATION
Relate two work areas by a key value or record number
------------------------------------------------------------------------------
Syntax

SET RELATION TO [<expKey> | <nRecord> INTO <xcAlias>]
[, [TO] <expKey2> | <nRecord2> INTO <xcAlias2>...]
[ADDITIVE]

Arguments

TO <expKey> is an expression that performs a SEEK in the child work
area each time the record pointer moves in the parent work area. For
this to work, the child work area must have an index in USE.

TO <nRecord> is an expression that performs a GOTO to the matching
record number in the child work area each time the record pointer moves
in the parent work area. If <nRecord> evaluates to RECNO(), the
relation uses the parent record number to perform a GOTO to the same
record number in the child work area. For a numeric expression type of
relation to execute correctly, the child work area must not have an
index in USE.

INTO <xcAlias> identifies the child work area and can be specified
either as the literal alias name or as a character expression enclosed
in parentheses.

ADDITIVE adds the specified child relations to existing relations
already set in the current work area. If this clause is not specified,
existing relations in the current work area are released before the new
child relations are set.

SET RELATION TO with no arguments releases all relations defined in the
current work area.

Description

SET RELATION is a database command that links a parent work area to one
or more child work areas using a key expression, record number, or
numeric expression. Each parent work area can be linked to as many as
eight child work areas. A relation causes the record pointer to move in
the child work area in accordance with the movement of the record
pointer in the parent work area. If no match is found in the child work
area, the child record pointer is positioned to LASTREC() + 1, EOF()
returns true (.T.), and FOUND() returns false (.F.).

The method of linking the parent and child work areas depends on the
type of <expKey> and presence of an active index in the child work area.
If the child work area has an active index, the lookup is a standard
SEEK. If the child work area does not have an active index and the type
of <expKey> is numeric, a GOTO is performed in the child work area
instead.

Notes

. Cyclical relations: Do not relate a parent work area to itself
either directly or indirectly.

. Soft seeking: SET RELATION does not support SOFTSEEK and
always behaves as if SOFTSEEK is OFF even if SOFTSEEK is ON. This
means that if a match is not found in the child work area, the child
record pointer is always positioned to LASTREC() + 1.

. Record number relations: To relate two work areas based on
matching record numbers, use RECNO() for the SET RELATION TO
expression and make sure the child work area has no active indexes.

Examples

. This example relates three work areas in a multiple parent-child
configuration with Customer related to both Invoices and Zip:

USE Invoices INDEX Invoices NEW
USE Zip INDEX Zipcode NEW
USE Customer NEW
SET RELATION TO CustNum INTO Invoices, Zipcode INTO Zip
LIST Customer, Zip->City, Invoices->Number, ;
Invoices->Amount

. Sometime later, you can add a new child relation using the
ADDITIVE clause, like this:

USE BackOrder INDEX BackOrder NEW
SELECT Customer
SET RELATION TO CustNum INTO BackOrder ADDITIVE

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top