Scans records of an external file using a given index.
Xfor each <file_name> [Index <index_name>]
[Where <condition1>]
…
[Where <conditionN>]
[option distinct]
[When none]
Xendfor
View Syntax conventions
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
Specifies the code to be executed when the Xfor each does not filter any record.
Objects: Procedure, Web Panel
This command 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 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 the 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.
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. |
For Each command
Xfor First Command
Data View object