[rules-users] Check if a pattern binding exists in the RHS

Edson Tirelli tirelli at post.com
Tue Aug 19 08:55:00 EDT 2008


   This is a surprise for me, because you should get a compilation error for
that. What version of Drools are you using?

   Anyway, you can't do that. When you use "or", Drools will internally
create one subrule for each logical branch in your LHS. So, any variable you
use in the RHS must be bound in all possible logical branches.

   []s
   Edson

2008/8/19 hatzlj <hatzl.j at a1.net>

>
> Hello everybody,
>
> on the LHS of my rule i connect several Conditions with OR and have
> different variable bindings for this Condition. Now - if any of this
> conditions does not fire, i assume that the binding variable is not
> created,
> so I can't access it in the RHS. This results in an null pointer exception
> when I call the fireAllRules-Command in my Java Application.
>
> A simple rule example:
> rule "Rule 1"
>   when
>      HKT: Parameter(parameterCode = "HKT", value < normalFloor) or
>      GGT: Parameter(parameterCode = "GGT", value < normalFloor) or
>      HSR: Parameter(parameterCode = "HSR", value < normalFloor) and
>      GOT: Parameter(parameterCode = "GOT", value > normalFloor)
>
>   then
>      System.out.println(HKT.toString();
>
> end
>
> So my Question is: Is there any way to check in the RHS wheter the pattern
> binding has been created or not or do i have to change the way of writing
> my
> rules (which i do not want to)?
>
> thanks,
> hatzlj
> --
> View this message in context:
> http://www.nabble.com/Check-if-a-pattern-binding-exists-in-the-RHS-tp19032260p19032260.html
> Sent from the drools - user mailing list archive at Nabble.com.
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
Edson Tirelli
JBoss Drools Core Development
JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080819/6196229b/attachment.html 


More information about the rules-users mailing list