You really ought to read all the pertaining sections in the Drools Expert manual and experiment. Nobody can write complex rules without some exercise.<br><br><div class="gmail_quote">2010/2/24 dhari <span dir="ltr"><<a href="mailto:sdhari@hotmail.com">sdhari@hotmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<p>Thanks Jeffery.
I'll try this but what if I have more complex condition e.g. </p>
<p><br>
Order ($discount : discount, $items : items)<br>
Item(grade > 3 && (quantity < 5 || $discount > 10)) from $items</p></blockquote><div><br>Again, you are using a condition on discount not next to the field in the fact where it occurs (i.e., Order); it's just not possible to write it this way.<br>
<br>Order( discount > 10, $items : items ) # all Orders where discount > 10 <br>Item( grade > 3, quantity < 5 ) from $items # and each of its Items where grade > 3 and quantity < 5<br><br>There is no need to use && to combine two conditions for the same fact.<br>
<br>Now if you need to detect Order Items with grade > 3 where either the quantitiy of the Item is < 5, or the Order's discount > 10, (or both) you'd have to write<br><br>Order( $discount : discount, $items : items ) # all Orders<br>
Item( grade > 3, $quantity : quantity) from $items # and each of its Items where grade > 3<br>eval( $discount > 10 || $quantitiy < 5 ) # and discount > 10 or quantity < 5 (or both)<br>
<br>-W<br><br><br></div></div><br>