[rules-users] Issue with simple accumulate sum rule

stelomax stephen.lomax at mattelli.com
Fri Sep 13 05:54:20 EDT 2013


I am having an issue with a very (VERY) simple rule.

This is being called from a rule flow.  There are 2 "Testval" facts, both
have an "xval" of 300.  When the flow is executed i get the following output

Total xval: 0.0
300
Total xval: 0.0
300


This shows me a few things

1) The rule is firing
2) My facts are populated correctly with values

However the Sum is not working and always has a result of 0.0.



------------------------------------------------------------------------------------
dialect "java" 
ruleflow-group "TestSum" 
when 

Testval($xval2:xval) 

 $total:Number() from accumulate(
	Testval($xval:xval),
	sum($xval)
 ) 

then

System.out.println("Total xval: " + $total); 
System.out.println($xval2);
-----------------------------------


I simplified the rule to see if i was loosing my mind.  With the below rule
the sum works correctly (as it is summing the static value (1). And i get
the following output:

Total xval: 2.0


------------------------------------------------------------------------------------
dialect "java" 
ruleflow-group "TestSum" 
when 



 $total:Number() from accumulate(
	Testval($xval:xval),
	sum(1)
 ) 

then

System.out.println("Total xval: " + $total); 

-----------------------------------


I have been racking my brain for a full day now..any pointers would be
great!

Thanks gurus

Steve



--
View this message in context: http://drools.46999.n3.nabble.com/Issue-with-simple-accumulate-sum-rule-tp4025933.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list