<br>&nbsp;&nbsp;&nbsp; Hi Alessandro, just saw your e-mail and answered to you, but basically no-loop will not work for cases like this.<br>&nbsp;&nbsp;&nbsp; Either specify your constraints in a way they prevent the loop or use lock-on-active.<br><br>
rule &quot;Nota final das questoes&quot;
<br>&nbsp;&nbsp; when
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $qr : QuestionarioResposta( $nf : notaFinal )
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $result : Number( this != $nf )
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from accumulate( 
QuestaoResposta($nota:nota,$peso:questao.questaoPeso.peso)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from $qr.questoesResposta,
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sum( $nota * (Double)$peso ) 
)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp; then
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; modify( $qr ) {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setNotaFinal($result)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
<br>end<br><br>&nbsp;&nbsp;&nbsp; Hope it helps.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Edson<br>&nbsp; <br><br><div class="gmail_quote">2008/5/5 Alessandro Lazarotti &lt;<a href="mailto:alessandro@siq.com.br">alessandro@siq.com.br</a>&gt;:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
It&#39;s a bug?<br><font color="#888888">
<br>
Alessandro Lazarotti escreveu:</font><div><div></div><div class="Wj3C7c"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Sorry, my code is ugly in last email...<br>
This is more clean:<br>
<br>
rule &quot;The Rule&quot;<br>
 &nbsp; no-loop true<br>
 &nbsp; when<br>
<br>
 &nbsp; &nbsp; &nbsp; questionarioResposta : QuestionarioResposta()<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;$resultFinal : Number() from accumulate(QuestaoResposta($peso:questao.questaoPeso.peso)<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;from questionarioResposta.getQuestoesResposta(),<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sum( $peso ))<br>
 &nbsp; then<br>
 &nbsp; &nbsp; &nbsp; System.out.println($resultFinal);<br>
 &nbsp; &nbsp; &nbsp; update( questionarioResposta );<br>
end<br>
<br>
This is a recursive and no-loop is ignored.<br>
Who knows why this?<br>
<br>
Thanks<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
Alessandro Lazarotti escreveu:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi<br>
When I use accumulate and update, no-loop is ignored and the rule is<br>
recursive.<br>
Why?<br>
<br>
The Rule:<br>
<br>
rule &quot;Nota final das questoes&quot;<br>
 &nbsp; &nbsp;no-loop true<br>
 &nbsp; &nbsp;when<br>
</blockquote>
<br>
<br>
<br>
<br>
<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;questionarioResposta : QuestionarioResposta()<br>
 &nbsp; &nbsp; &nbsp; &nbsp;$result : Number() from<br>
accumulate(QuestaoResposta($nota:nota,$peso:questao.questaoPeso.peso)  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; from questionarioResposta.getQuestoesResposta(),  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum($nota * (Double)$peso))<br>

 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$resultFinal : Number() from<br>
accumulate(QuestaoResposta($nota:nota,$peso:questao.questaoPeso.peso)  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; from questionarioResposta.getQuestoesResposta(),  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum( $peso ))  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;then<br>

 &nbsp; &nbsp; &nbsp; &nbsp;System.out.println($result.doubleValue() / $resultFinal.doubleValue()); &nbsp; &nbsp; &nbsp; &nbsp; questionarioResposta.setNotaFinal($result.doubleValue() /<br>
$resultFinal.doubleValue());<br>
 &nbsp; &nbsp; &nbsp; &nbsp;update( questionarioResposta );<br>
end<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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>
<br>
</blockquote>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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>
<br>
</blockquote>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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>
</div></div></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>