4D v16.3

RELATE ONE SELECTION

Home

 
4D v16.3
RELATE ONE SELECTION

RELATE ONE SELECTION 


 

RELATE ONE SELECTION ( manyTable ; oneTable ) 
Parameter Type   Description
manyTable  Table in Many table name (from which the relation starts)
oneTable  Table in One table name (to which the relation refers)

The RELATE ONE SELECTION command creates a new selection of records for the table oneTable, based on the selection of records in the table manyTable and loads the first record of the new selection as the current record.

This command can only be used if there is a relation from manyTable to oneTable. RELATE ONE SELECTION can work across several levels of relations. There can be several related tables between manyTable and oneTable. The relations can be manual or automatic.

RELATE ONE SELECTION uses the "shortest" path to pass from the starting table to the destination table. If there are existing paths of the same size and you need to control the used path, you may consider using the SET FIELD RELATION command.

Example  

The following example finds all the clients whose invoices are due today.

Here is one way of creating a selection in the [Customers] table, given a selection of records in the [Invoices] table:

 CREATE EMPTY SET([Customers];"Payment Due")
 QUERY([Invoices];[Invoices]DueDate=Current date)
 While(Not(End selection([Invoices])))
    RELATE ONE([Invoices]CustID)
    ADD TO SET([Customers];"Payment Due")
    NEXT RECORD([Invoices])
 End while

The following technique uses RELATE ONE SELECTION to accomplish the same result:

 QUERY([Invoices];[Invoices]DueDate=Current date)
 RELATE ONE SELECTION([Invoices];[Customers])

Note: Since version 11, this code can be written as follows without any loss of performance:

 QUERY([Customers];[Invoices]DueDate=Current date)



See also 

QUERY
RELATE MANY SELECTION
RELATE ONE
Sets

 
PROPERTIES 

Product: 4D
Theme: Relations
Number: 349

This command changes the currrent recordThe command changes the current selectionThis command can be run in preemptive processes

 
HISTORY 

Modified: 4D v6

 
ARTICLE USAGE

4D Language Reference ( 4D v16)
4D Language Reference ( 4D v16.1)
4D Language Reference ( 4D v16.2)
4D Language Reference ( 4D v16.3)