<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:blue;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:Calibri;
        color:navy;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
 /* List Definitions */
 @list l0
        {mso-list-id:217590752;
        mso-list-type:hybrid;
        mso-list-template-ids:-628298830 -2091994846 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
        {mso-level-tab-stop:.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:11.0pt;
        font-family:Calibri;
        color:navy;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=blue>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'>Hi,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'>Thanks for the reply..<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'>--The sequential option is set to <b><i><span
style='font-weight:bold;font-style:italic'>false</span></i><o:p></o:p></b></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'>--Using&nbsp; <i><span style='font-style:
italic'>StatelessKnowledgeSession<o:p></o:p></span></i></span></font></p>

<p class=MsoNormal><i><font size=2 color=navy face=Calibri><span
style='font-size:11.0pt;font-family:Calibri;color:navy;font-style:italic'><o:p>&nbsp;</o:p></span></font></i></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'>Summary what I intend to achieve,<o:p></o:p></span></font></p>

<ol style='margin-top:0in' start=1 type=1>
 <li class=MsoNormal style='mso-list:l0 level1 lfo1'><font size=2 color=navy
     face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>In
     first rule, I am doing calculation on three different columns and putting it
     in </span></font><b><i><span style='font-weight:bold;font-style:italic'>sumOfThree</span></i>
     </b>property of ActualSum and inserting it in WM. Let say I have four
     facts.<o:p></o:p></li>
 <li class=MsoNormal style='color:navy;mso-list:l0 level1 lfo1'><font size=2
     color=navy face=Calibri><span style='font-size:11.0pt;font-family:Calibri'>In
     Second Rule, I am inserting distinct audit trail in DistinctAT. Lets say I
     have two distinct AT.<o:p></o:p></span></font></li>
 <li class=MsoNormal style='color:navy;mso-list:l0 level1 lfo1'><font size=2
     color=navy face=Calibri><span style='font-size:11.0pt;font-family:Calibri'>In
     Third Rule, I am assuming 4 Facts of ActualSum and 2 Facts of DistinctAT
     already available in WM. Now I want to get sum of sumOfThree group by AT,
     which I am trying to get using Accumulate function.<o:p></o:p></span></font></li>
</ol>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><b><i><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy;
font-weight:bold;font-style:italic'>OutPut I am getting:<o:p></o:p></span></font></i></b></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>AT
:1001<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>Done!<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>Done
Main Rule, total :-40.0<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>AT
:1000<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>Done!<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>Done
Main Rule, total :210.0<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>AT
:1000<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>Done
Main Rule, total :160.0<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>AT
:1000<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>Done
Main Rule, total :260.0<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='margin-left:.25in'><font size=2 color=navy
face=Calibri><span style='font-size:11.0pt;font-family:Calibri;color:navy'>INFO:
Number of generated exceptions &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'>Here I see the last rule is getting
fired every time ActualSum fact is inserted in first rule. And as the facts are
available one by one, these are available to Accumulate function used in third
Rule. Actually I am expecting only two exceptions one for AT:1001 and AT:1000
with total of -40 and 260 resp.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'>Please advise.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'>P.S.&nbsp; Please ignore &#8220;</span></font>$lfna_SEI
and $r_SE<font size=2 color=navy face=Calibri><span style='font-size:11.0pt;
font-family:Calibri;color:navy'>&#8221;.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'>Thanks,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Calibri><span style='font-size:
11.0pt;font-family:Calibri;color:navy'>Ritesh<o:p></o:p></span></font></p>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <b><span style='font-weight:bold'>On
Behalf Of </span></b>Michael Anstis<br>
<b><span style='font-weight:bold'>Sent:</span></b> Friday, September 17, 2010
12:43 PM<br>
<b><span style='font-weight:bold'>To:</span></b> Rules Users List<br>
<b><span style='font-weight:bold'>Subject:</span></b> Re: [rules-users] How to
activate/deactivate a rule.</span></font><o:p></o:p></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Have you tried running what you have?<o:p></o:p></span></font></p>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>I'd expect it to give the result you expect already (other than
throwing an error because&nbsp;$lfna_SEI and $r_SE are not bound in the last
rule and assuming&nbsp;chkRuleExpre is constant over time). Rules do not
normally execute in any sequential order (unless you explicitly make them so).
As the facts are inserted into WM they are matched against your rules and
activations scheduled. When all facts are inserted into WM and you call
fireAllRules the activations are played out and &quot;truth maintenance&quot;
ensures the &quot;result&quot; of their firing is consistent with the facts in
WM (either inserted by rules or the programmer). This is in essence &quot;how
inference engines&quot; work.<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>After you've called fireAllRules (and assuming you have a stateful
session) you insert more ABC's then you'd have to expect the last rule to be
re-evaluated - following another call to fireAllRules. So in part when rule 3
ultimately gives the &quot;correct&quot; answer depends upon when you stop
inserting ABC's.<o:p></o:p></span></font></p>

</div>

<div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>On 17 September 2010 07:35, Ritesh &lt;<a
href="mailto:ritesh.khot@sungard.com">ritesh.khot@sungard.com</a>&gt; wrote:<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><br>
Hi,<br>
<br>
I have 3 rules in my drl file and want the last one should get fired only<br>
after all the facts in rule1 and rule2 gets inserted in working memory.<br>
Please see below code for more understanding. Please suggest.<br>
<br>
Thanks<br>
<br>
declare DistinctAT<br>
&nbsp; &nbsp; d_auditT : String<br>
end<br>
<br>
declare ActualSum<br>
&nbsp; &nbsp; auditT : String<br>
&nbsp; &nbsp; sumOfThree : BigDecimal<br>
end<br>
<br>
rule &quot;insert combined sum&quot;<br>
&nbsp; &nbsp; &nbsp; &nbsp;dialect 'java'<br>
when<br>
&nbsp; &nbsp;ABC( $a:A, $b:B, $c:C )<br>
<br>
then<br>
&nbsp; &nbsp; &nbsp; &nbsp;BigDecimal actSum = $c.multiply(0.13);<br>
&nbsp; &nbsp; &nbsp; &nbsp;ActualSum $as = new ActualSum();<br>
&nbsp; &nbsp; &nbsp; &nbsp;$as.setAuditT($a);<br>
&nbsp; &nbsp; &nbsp; &nbsp;$as.setSumOfThree(actSum);<br>
&nbsp; &nbsp; &nbsp; &nbsp;insert($as);<br>
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(&quot;AT :&quot; + $movAuditT);<br>
end<br>
<br>
rule &quot;insert distinct AT&quot;<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp;dialect 'java'<br>
when<br>
&nbsp; &nbsp;$a : ActualSum( $AT : auditT )<br>
&nbsp; &nbsp; &nbsp; &nbsp;not DistinctAT( d_auditT == $AT )<br>
then<br>
&nbsp; &nbsp; &nbsp; &nbsp;DistinctAT $disAT = new DistinctAT();<br>
&nbsp; &nbsp; &nbsp; &nbsp;$disAT.setD_auditT($AT);<br>
&nbsp; &nbsp; &nbsp; &nbsp;insert($disAT);<br>
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(&quot;Done!&quot;);<br>
end<br>
<br>
rule &quot;Get Sum Group by AT&quot;<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp;dialect 'java'<br>
when<br>
<br>
DistinctAT( $dAT: d_auditT )<br>
<br>
$total : Double()<br>
from accumulate( ActualSum( auditT == $dAT, $actSum_Main : sumOfThree ),<br>
sum( $actSum_Main ) )<br>
<br>
eval(<br>
&nbsp; &nbsp; &nbsp; &nbsp;chkRuleExpre( $total,$lfna_SEI,$r_SEI )<br>
)<br>
<br>
then<br>
&nbsp; &nbsp; &nbsp; &nbsp;System.out.println(&quot;Done Main Rule, total
:&quot; + $total);<br>
end<br>
<font color="#888888"><span style='color:#888888'><br>
--<br>
View this message in context: <a
href="http://drools-java-rules-engine.46999.n3.nabble.com/How-to-activate-deactivate-a-rule-tp1516088p1516088.html"
target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/How-to-activate-deactivate-a-rule-tp1516088p1516088.html</a><br>
Sent from the Drools - User mailing list archive at Nabble.com.<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></span></font><o:p></o:p></span></font></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

</div>

</div>

</body>

</html>