FOREACH Command

FOREACH — Return data rows of a returned datamodel.

Synopsis

FOREACH data_model_name

Introduction

The FOREACH command returns all rows from a data model. Entries in the data model can be referenced as:

  1. M-_col_no.datamodel_name

  2. M-external_field_name.datamodel_name

  3. M-alias.datamodel_name

Columns which have no obvious name (result of calculation for instance), can only be referenced by the column number. Alternatively, the complete data model can be copied to a Record or VariableGroup in a single assignment statement.

Arguments

data_model_name

Valid and existing data model object.

Example

. . .
. . .
CLEAR DATAMODEL dm_customer
SQL QUERY Order COMMAND "select * from " T-Cust DATAMODEL dm_customer
FOREACH dm_customer
    CALL PrintLabel M-_col_1.dm_customer M-cust_name.dm_customer
ENDFOR
. . .
. . .
CLEAR DATAMODEL dm_customer
DATAMODEL SELECT dm_customer TABLE Cust
FOREACH dm_customer
    LET R-Customer = O-dm_customer
    CALL PrintLabel F-Cust_Id.Customer F-Name.Customer
ENDFOR
. . .
. . .

Related Commands

BREAK CONTINUE DATAMODEL ENDFOR SQL