The foreach Loop

The foreach loop performs an action on every record stored in a variable of type RecordList.

The foreach loop has the following syntax.

foreach( variable of type RecordList )
        {
            List of stitcher rules to execute
        }

Example

The following example shows how the foreach loop repeats the list of stitcher rules for every record in the list.

foreach( remoteNames )
        {
            ExecuteOQL
                (
                    "insert into CDPLayer.entityByNeighbor
                        (
                            m_Name, m_NbrName, m_NbrType
                        )
                        values
                        (
                            eval(text, '&m_LocalName'),
                            eval(text, '&m_Name'),
                            eval(int, '$RemoteNeighbor')
                        );"
                );
        }

The example assumes that a variable called remoteNames has already been defined and a list of OQL records has been assigned to it. The foreach loop executes the specified OQL insert for every record in the list, extracting the values to insert from the records using eval statements.