all (objects)

The all <objects> construct introduces a collection of objects.

Purpose

You use this construct to filter a collection of objects.

Syntax

all <objects> [in <list>][,where <test>[,]]

Description

all <objects> collects all the object instances of the working memory. You can add an optional in <list> filter to access data from object collections defined in the object model. You can also add a where clause to test one or more conditions on an object. When you use the where clause with collections of objects, the comma before the where is required, whereas the comma at the end of the condition is optional.

Example

The following rule checks whether the total amount of all the coupons is at least 150. If this condition is true, a message is displayed to grant the customer a 10% discount on the next trip.

if
    the total amount of all coupons in the coupons of 'the customer' is at least 150 
then
    print "10% discount on the next trip";      

The following rule checks whether the average price of all the purchases is between 100 and 200. If this condition is true, a message is displayed.

if
    the average amount of all purchase events,
        where the status of each purchase event is On Board, is between 100 and 200
then
    print "The average amount of on-board purchases is between 100 and 200";

The following rule checks whether the average price of all the tickets of this trip is between 100 and 200.

if
    the average price of all tickets in the tickets of 'the trip' is between 100 and 200
then
    print "The average price of all the tickets of this trip is between 100 and 200";

The following rule checks whether the number of purchases is more than 100. If this condition is true, a message is displayed. Notice that when the number of operator is applied to a collection that is defined by the all construct, the article all is removed to improve readability.

if 
    the number of purchase events is more than 100
then 
    print "send 25% discount voucher";