Official Content

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: 

  1.     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.
  2.     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.
  3.     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 groupretrieve the records corresponding to the group. Read more at Nested For each commands to implement a Control Break.  
Last update: December 2025 | © GeneXus. All rights reserved. GeneXus Powered by Globant