Reporting information from multiple tables
- Last Updated: January 17, 2024
- 1 minute read
- OpenEdge
- Version 12.8
- Documentation
Each order has one or many order lines, each of which
relates to a single inventory item. Accounting needs to pull information
from the OrderLine 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.
The code fragment from i-10-08.p shows the completed
structure of nested FOR EACH blocks.
i-10-08.p
|
These notes explain the code highlights:
- The
WHEREclause of the thirdFOR EACHrelates the OrderLine table back to the Order table. - For each OrderLine, there is a single
Item record that contains information about the ordered item. A
simple
FINDstatement retrieves this information. - The report totals the result of an expression. Notice the absence
of the
BYbreak group syntax. - The
FORMAToption 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 following shows the output of the final version of this report:
