Nested For each commands are used to iterate over each record in a table to retrieve multiple records from another table (which may be the same table).
For each [BaseTrn]
....
For each [BaseTrn]
...
Endfor
...
endfor
When GeneXus detects nested For each commands, it first determines the Base Table of each one. Then, it interprets one of these cases:
- For each record in a table, you want to retrieve related records from another table. Read more at Nested For Each commands to implement a Join.
- For each record in a table, you want to retrieve all records from another table. Read more at Nested For Each commands to implement a Cartesian Product.
- You want to process information by groups; that is, group the records from a table by the value of an attribute or group of attributes, and, for each group, retrieve the records corresponding to the group. Read more at Nested For each commands to implement a Control Break.