Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- CA-Clipper 5.2 . The Guide To CA-Clippe - <b>set relation</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 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

 Files:  Library is CLIPPER.LIB.

See Also: DBRELATION() DBRSELECT() FOUND() RECNO()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson