Hello,

  I have following rule:

rule "Remove unsued phones"
        when
                exists Customer()
                not Customer(phone == $value)
                $unused: Phone($value: value)
        then
                retract($unused);
end

There might be multiple Customer and Phone facts in the working memory and the 
purpose of the rule is to remove phones that do not belong to any of the 
customers. The rule should not be activated while there are no Customers in WM 
- hence the "exists Customer()". This is becaus there are other rules, taht 
might use the phones to lookup customers.

There Phone with value = "test" in working memory when Customer with phone = 
"test" is inserted. BTW: Both facts are immutable.

The behavior differs depending on order of the 3 patterns in the LHS of the 
rule.

1) If the "exists Customer()" is first activation is created
        - this is wrong since the "exists Customer()" shall be false

2) if I move the "exists Customer()" between the other patterns activation is 
created and immediatelly canceled
        - this is also wrong since, although in my case (where are no side 
effects) it works

3) Finally if the "exists Customer()" comes last the then activation is not 
created at all
        - this is correct

Is this bug or am I missing something important about rule language? Rewriting 
the LHS with expicit infix and does not help:

                (exists Customer()) and
                (not Customer(phone == $value)) and
                ($unused: Phone($value: value))


Ales

FYI: I'm using 5.5.0.Final
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to