Globals should only be used for data that is constant over the life of the working memory, which is not so in your case.<br><br>Maybe you should just use a fact counter. If you don&#39;t want to affect your code you could insert it in a separate rule.<br>
<br>when<br>then<br><br><br><div class="gmail_quote">On Tue, Dec 9, 2008 at 9:05 AM, techy <span dir="ltr">&lt;<a href="mailto:techluver007@gmail.com">techluver007@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Hello,<br>
I would like to take 100 sampling facts for rule and persist it in the db<br>
and ignore other data.<br>
How Can I maintain the counter? as global variable? Please clarify with<br>
sample code.<br>
I tried following way and but it does not work as expected.<br>
<br>
Ex:<br>
global Integer counter;<br>
rule &quot;get sampling data&quot;<br>
 &nbsp; when fact : Foo(some condition) &amp;&amp; eval(counter &lt;= 100)<br>
 &nbsp; then<br>
 &nbsp; &nbsp;counter++<br>
 &nbsp; // do some condition<br>
end<br>
<font color="#888888">--<br>
View this message in context: <a href="http://www.nabble.com/having-counter-in-drl-tp20904469p20904469.html" target="_blank">http://www.nabble.com/having-counter-in-drl-tp20904469p20904469.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>Steven Williams<br><br>Supervising Consultant<br><br>Object Consulting<br>Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501<br><a href="mailto:steven.williams@objectconsulting.com.au">steven.williams@objectconsulting.com.au</a><br>
<a href="http://www.objectconsulting.com.au">www.objectconsulting.com.au</a><br><br>consulting | development | training | support<br>our experience makes the difference<br>