Databases Reference
In-Depth Information
Up to this point, whenever we have defined a rule, we have just
been specifying the test part of the pattern. Behind the scenes, the
rule editor has defaulted the pattern values, with the pattern type set
to
for each case where
, the
fact
type
set to the fact specified in the
test, and the
variable
name set to the same name as the
fact
type
.
For our rule, we just want to test for the existence of a fact of type
TAuctionItem
, so
we will keep the default pattern (we will look at how to use a different pattern type
in a moment).
To do this, click on
<variable>
and specify an appropriate name, next click on
<fact type>
and select
TAuctionItem
from the drop-down list, as shown in the
following screenshot:
We don't need to specify a test as all we are doing is checking for the existence of
the fact. The action part of the rule contains an
assign
statement to initialize our
global variable. As you can see from the following screenshot, despite having to use
Advanced Mode
, the rule to initialize our global variable is pretty straightforward:
The other point worth noting is that we have specified a priority of
highest
(the default is
medium
) for the rule. This is to ensure that this rule is fired
before any of the other rules which reference this variable.