[rules-dev] How to get value of global variable from one rule to another

Mark Proctor mproctor at codehaus.org
Tue Jun 12 08:51:16 EDT 2007


This list is for discussions on the development of the drools project, 
for help on how to use drools please use the user mailing list.

Thank you.

Mark
Alexander Komissarov wrote:
> Hello,
>
> Please give me advice for best way storing global variables.
>
> global java.lang.Integer res;
> global java.lang.Integer res2;
> ...
>
> I've several number of rules. One rule has variable initialization e.g.:
>
> ...
> rule "AmountsAreNotNull" salience 20
>     when
>         < conditions >
>     then
>        ...
>         res = new Integer(a.compareTo(new BigDecimal(25)));
>         res = (res == -1)?0:res;
>         res = (res == -1)?0:res;
>         res2 = new Integer(a.compareTo(b));
>         res2 = (res2 == -1)?0:res2;
>        ...
> end
>
> The values of these variables are proper and equal 1
>
> Then next rule has comparing for res|res2 values, but they have lost 
> their values (res == null and res2 == null)
>
> rule "CompareValues" salience 10
>     when
>         res:Integer(intValue == 0)
>         res2:Integer(intValue == 0)
>         result:List()
>     then
>         result.add(Boolean.TRUE);
> end
>
> What decision you can advise me to save variables value between rules?
> Thanks.
> ____________________
> Regards,
> Komissarov Alexander
> mail: aleks.komissarov at gmail.com <mailto:aleks.komissarov at gmail.com>
> icq: 239128267
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> rules-dev mailing list
> rules-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20070612/e9d70420/attachment.html 


More information about the rules-dev mailing list