Developer

<<foreach>>

The <<foreach...>> function allows for iteration over an object collection property. This function takes as its single argument the name of an object collection. The expression can contain text and SDML that will be returned once for each member of the named collection. If the collection is empty, nothing is returned.

This function allows you to iterate over a collection of objects. The expression specified will be returned once for each member and normally contains SQL and SDML that is to be processed for a single object. The <<foreach...>> function is commonly used for INSERT statements, which can only insert a single record at a time. It is often seen in SQL steps used to update a client exchange table during fetch processing.

The expression to the function can also contain an additional data tag, <<my>>. This tag represents the current member of the collection being processed by the function. To use the <<my>> data tag, the same syntax is used as in other areas where property data tags are used.

There is also the optional <<key>> tag available within a <<foreach>> expression, which provides the name of the current key being iterated over. This is normally only used in conjunction with SQL Flunkies, explained later in this chapter.

Arguments

    <<foreach objectCollectionArg expression>>
  • objectCollectionArg The name of a collection that the function is to iterate over.
  • expression The text to be returned once for each member of the collection. The expression can contain plain text and SDML. It will be submitted for expansion once for each collection member.

Parameters

None