where (test)
This construct matches objects against tests.
Purpose
Matches objects against tests.
Syntax
where <test>[,]*
Description
In the definitions part of a rule, you
can use one or more where clauses
with the set construct
to test that an object meets one or more conditions in order to be
a valid value for the variable being declared. In the definitions part of the rule,
the where statement does
not end with a comma. Instead, each set construct
should end with a semi-colon (;).
In the if part of a rule, you can use
one or more where clauses
in count conditions (there is more
than, there is less than,
and so on) to test that an object meets one or more conditions before
being counted.
In a where construct,
an implicit variable that refers to the current instance of the object
being tested is automatically declared. In the test, you can thus
refer to potential instances of the variable as this <object type> (or each <objet type> if they
are part of a collection.)
Example
The following example shows the definitions part of a rule that
defines the local variable ‘expensive items’ as a collection
of items whose price is greater than 100. The implicit variable each item is used in the where clause to refer to each item object in the collection.
definitions
set ’expensive items’ to all items
where the price of each item is more than 100;
The
following example shows the where clause
used together with the there is
one construct in the if part
of a rule to test if there is a customer older than 100. The implicit
variable this customer is
used in the where clause
to refer to the customer object being tested.
if
there is one customer
where the age of this customer is more than 100,