Reference > Rule Languages > Business Action Language > BAL Constructs > called <variable>

Summary

Provides a name for a variable declared in a for each action statement.

Syntax

called <variable>,

Description

When using a for each statement to perform an action on a set of items, a variable is created automatically to allow you to refer to each item in turn as `this item' (see the first example below). However, if you nest one for each loop inside another, you must give the variable in the outer loop a name so that you can reference it from within the inner loop (see the second example below).

Example

The following rule shows a simple for each action statement. There is no need to use the called construct in this case.

if
    the category of the customer is Gold
then
    for each customer in ‘senior customers’:
        - send flowers to this customer;

The following rule shows two nested for each statements. The called construct is used so hat each customer can be explicitly referred to from within the nested for each loop.

if
   the category of the customer is Gold
then
   for each customer called c, in ‘senior customers’:
      - for each account in ‘new accounts’:
         - send a statement for this account to the mailing address of c;

Related Concepts

Rule Actions

Related Tasks

Creating Business Rules

Related Reference

else
then
for each <object> in <list>

Related Samples and Tutorials

Tutorial: Creating Business Rules