Release 10.1A: OpenEdge Development:
Programming Interfaces

> ## Reporting information from two tables

> The next step is to look at the orders for each selected customer. This information is in the Order table. Another `FOR` `EACH` inside the first accomplishes this task. For each iteration of the outer block, the inner block finds all the related information. The `WHERE` clause establishes the relationship between the two tables.

> The code below from `i-10-07.p` shows the nested `FOR` `EACH` blocks:

> i-10-07.p
>     .
>     .
>     .
>       FOR EACH Customer FIELDS (Balance Credit-Limit Name Contact Cust-Num)
>           WHERE Balance >= (Credit-Limit * .85)
>           WITH STREAM-IO:
>           DISPLAY Name FORMAT "x(20)" Contact FORMAT "x(15)"
>               Balance Credit-Limit WITH NO-BOX.

>           FOR EACH Order FIELDS (Cust-Num Order-Num Order-Date Ship-Date
>               Promise Date) WHERE Order.Cust-Num = Customer.Cust-Num
>               WITH STREAM-IO:
>               DISPLAY Order-Num Order-Date Ship-Date
>                   Promise-Date SKIP(1) WITH 2 COLUMNS.
>           END.
>       END.
>     .
>     .
>     .

> The output from this procedure (following) shows how the related information ends up grouped together:

> Notice that for a single iteration of the Customer data, there may be several iterations of Order data. Earlier you learned that the default frame of an iterating control block is a down frame. When you nest control blocks, only the innermost block uses a down frame. The other blocks execute one iteration at a time. This default behavior lets the related information group together naturally with the iteration of the blocks.

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