Xfor Each command

Official Content
This documentation is valid for:

To scan records of an external file using a given index.

Defines an iterative loop for an external file, using the specified index (if any) and filters data according to the Conditions declared in the Where statements.

When a Data View object without an associated table is defined, this command will obtain the required information to perform updates over an external file. If the Data View has an associated table the For Each command (X Evolution 2) may be used instead of the Xfor Each command.

GeneXus will try to optimize the search in an intelligent way, taking into account the index specified in the Xfor Each statement and conditions defined in the Where of the Xfor Each group. Xfor Each groups can be combined by nesting them or by defining them as parallel groups.

Syntax

Xfor each ‘file_name [ index index_name ]

       { [ Where condition ] } …

       [ option distinct ]

       [ When none ]

Xendfor

Where:
file_name
 Is the name of the Data View defined to access the external file.

index
 Defines the name of the index to be used.

index_name
 Is the name of the Data View Index.

where
 Clause that can be specified to establish a condition for data retrieval.

condition
Any valid logical expression.

option distinct
Only returns records where the set of values of the attributes referred to is unique.

when none
Specify the code to be executed when the Xfor each does not filter any record.

The differences between the For Each and the Xfor Each commands are:

For Each Xfor Each
Several tables may be associated with the Group. Only one table can be referenced.
The base table is inferred by GeneXus. The base table must be declared by the user.
The index is inferred by GeneXus according to the specified order. The index must be declared by the user.
Relationships between nested For Each groups are done by GeneXus No relationship is detected between nested Xfor each groups.

 


Scope

Objects: Procedure object, Web Panel object


 

See Also

For Each command (X Evolution 2)
Xfor First Command
Where Clause
option distinct
When None Clause

More here

Data View object

 





Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.