Progress
Language Tutorial
for Windows


Relating Record Options

Your tools for creating relationships among tables are the same statements that you’ve been working with throughout this chapter. Instead of working with a single table, you can use the same statements to work with more than one. This section introduces the new options that help with this task.

This is the relevant FOR EACH syntax.

SYNTAX
FOR EACH record-phrase [ , EACH record-phrase ] ... 

This is the relevant OPEN QUERY syntax.

SYNTAX
OPEN QUERY query FOR EACH record-phrase
  [ , EACH record-phrase ] ... 

This is the relevant record phrase syntax.

SYNTAX
record [ OF table ] [ WHERE expression ] 

Table 9–3 describes the syntax options.

Table 9–3: Record Relation Options 
Component
Description
OF table
Allows you to relate two tables. You can use OF only when the two tables share an identical field and that field is indexed in at least one of the tables.
FOR EACH Customer:
FOR EACH Order OF Customer
OF is considered a shortcut syntax for an explicit WHERE expression when OF is used to express this type of relationship:
WHERE order.cust.num = customer.cust.num
WHERE expression
Relates two tables in the same way OF does. With WHERE, however, the fields do not need to be indexed and they don’t have to have the same name.
FOR EACH Customer:
FOR EACH Order WHERE Order.Cust-Num = Customer.Cust-Num
EACH
record-phrase
Allows you to build compound FOR EACH and OPEN QUERY statements. For example, you can simplify this code:

FOR EACH Customer:
FOR EACH Order OF Customer.

by using the EACH phrase

FOR EACH Customer, EACH Order OF Customer:


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095