[rules-users] Accum question

Edson Tirelli tirelli at post.com
Fri Jul 27 10:08:12 EDT 2007


   Sorry, it is not clear what you are trying to do.
   There are a few clear mistakes in your rule:

1. You can't use the $totV variable inside the accumulate, since $totV is
the "result" of the accumulate.

2. You can't use variables bound inside accumulate outside of it, since
accumulate is a scope delimiter ($ciNo, $ciLineNo).

3. If you want to sum values, use sum() function, but if you want to count
occurrences, use the count() function.

4. This expression is wrong: "$totV > 1". You must either compare something
to a field or use an "eval()"  (inlined or not) to evaluate arbitrary
expressions.

5. I think it is simply a typo, but since the DRL is case sensitive, the
java class Number must be written with capital N.

   Maybe if you can explain with more common terms what rule you are trying
to write, we can help more... the best I could imagine is:

rule "00910 Pass XV sets"
  when
    $status : ValidationPassFailStatus()
    exists ValidationControl(validationNo == 910)
    CiLines( $ciNo : $ciNo, $ciLineNo : $ciLineNo, spiSecondary == "X" )
    Number( intValue > 1 )
          from accumulate( $c : CiLines( ciNo == $ciNo, ciLineNo ==
$ciLineNo,
                                         spiSecondary == "V" ),
                           count( $c ) )
 then
    $status.pass(910);
end

   Hope it helps.

   Edson

2007/7/27, Mike D <mike.dalaker at kewill.com>:
>
>
> Newbie question again...
>
> I'm trying to get a count of V lines if I have an X.  If more than 1 V
> line,
> I pass...  Obviously I can't have $totV on LHS, but you get my
> drift.  What
> is the correct syntax for this one?  I've been digging in the docs on
> accum,
> but can't find anything that fits what I'm trying to do.
>
> Thanks,
> Mike
>
> rule "00910 Pass XV sets"
>         when
>                 $status : ValidationPassFailStatus()
>                 exists ValidationControl(validationNo == 910)
>                 $totV  : number()
>                 from accumulate(CiLines($ciNo : $ciNo, $ciLineNo :
> ciLineNo, spiSecondary
> == "V"), sum($totV))
>                 CiLines(ciNo == $ciNo, ciLineNo == $ciLineNo, spiSecondary
> == "X", $totV > 1)
>         then
>                 $status.pass(910);
> end
>
>
> --
> View this message in context:
> http://www.nabble.com/Accum-question-tf4157809.html#a11829193
> 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
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  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/20070727/3dbe699f/attachment.html 


More information about the rules-users mailing list