Progress
Language Tutorial
for Character
Reporting Information from Multiple Tables
Each order has one or many order lines, each of which relates to a single inventory item. Accounting needs to pull information from the Order-Line and Item tables to get specific information about what was ordered. One more FOR EACH block, inside the existing block, completes the structure.
Once the procedure gathers all the information, accounting needs the procedure to calculate total prices. Nested FOR EACH blocks create sorted groups of information similar to break groups. Therefore, you can use the aggregate phrase to calculate total prices.
This code fragment comes from
lt-10-08.p
and shows the completed structure of nested FOR EACH blocks:
These notes explain the code highlights:
- The WHERE clause of the third FOR EACH relates the Order-Line table back to the Order table.
- For each Order-Line, there is a single Item record that contains information about the ordered item. A simple FIND statement retrieves this information.
- Here, the report totals the result of an expression. Notice the absence of the BY break group syntax.
- The FORMAT option here specifies a fairly complex format string. The result displays a leading dollar sign ($), suppresses the leading zeroes (z), and displays the credit symbol (CR) when the result is a negative value.
The output of the final version of this report follows:
![]()
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |