<br>&nbsp;&nbsp; There are several ways of doing that, and some where even mentioned by the other users. One easy way is to simply use &quot;accumulate&quot;:<br><br>rule &quot;update amount&quot;<br>&nbsp;&nbsp;&nbsp; no-loop<br>when<br>&nbsp;&nbsp;&nbsp; $f : Fact( name == &quot;amount&quot; )<br>
&nbsp;&nbsp;&nbsp; Number( $total : doubleValue ) from accumulate(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Charge( $amt : amount ),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sum( $amt ) )<br>then<br>&nbsp;&nbsp;&nbsp; modify( $f ) { setAmount( $total ) } <br>end<br><br>&nbsp;&nbsp;&nbsp; []s<br>&nbsp;&nbsp;&nbsp; Edson<br><br><div class="gmail_quote">
2008/11/4 Dan Seaver <span dir="ltr">&lt;<a href="mailto:dan.seaver@ge.com">dan.seaver@ge.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
I&#39;m trying to find a good technique for updating specific facts in working<br>
memory. What I&#39;m currently doing is something like this:<br>
<br>
Rule &quot;Update Amount&quot;<br>
 &nbsp; when<br>
 &nbsp; &nbsp; &nbsp;amountFact : Fact(name == &quot;Amount&quot;)<br>
 &nbsp; &nbsp; &nbsp;charge : Charge()<br>
 &nbsp; then<br>
 &nbsp; &nbsp; &nbsp;Double amount = amountFact.getAmount();<br>
 &nbsp; &nbsp; &nbsp;Double chargeAmount = charge.getAmount();<br>
 &nbsp; &nbsp; &nbsp;amountFact.setAmount(amount + chargeAmount);<br>
 &nbsp; &nbsp; &nbsp;update(amountFact);<br>
end<br>
<br>
The update statement causes an infinite loop.<br>
I tried using no-loop, which works if there is 1 charge, but not if there<br>
are more than one.<br>
<br>
Any help with solutions or strategies would be much appreciated.<br>
<font color="#888888">--<br>
View this message in context: <a href="http://www.nabble.com/Chart-notation%2C-update%2C-and-infinite-loops-tp20327483p20327483.html" target="_blank">http://www.nabble.com/Chart-notation%2C-update%2C-and-infinite-loops-tp20327483p20327483.html</a><br>

Sent from the drools - user mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br> &nbsp;Edson Tirelli<br> &nbsp;JBoss Drools Core Development<br> &nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>