<br> Rajesh,<br><br> See my previous e-mail, but just to complement, note that the equivalent translation of your SQL query:<br><br>select * from Students s where exists ( <br> select * from Modules m where m.student_name
= <a href="http://s.name">s.name</a> and m.score < 40 <br>)<br><br> To a rule is:<br><br>rule XXX<br>when<br> $s : Student( $name : name )<br> exists Modules( studentName == $name, score < 40 )<br>then<br> // do something
<br>end<br><br> Hope it helps,<br><br> []s<br> Edson<br><br><div><span class="gmail_quote">2007/5/31, Rajesh.Sachin10 <<a href="mailto:rajesh_sachin10@yahoo.co.in">rajesh_sachin10@yahoo.co.in</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>Following is the Example taken form the following URL:<br><br><a href="http://labs.jboss.com/file-access/default/members/jbossrules/freezone/docs/3.0.1/html_single/index.html#d0e2144">http://labs.jboss.com/file-access/default/members/jbossrules/freezone/docs/3.0.1/html_single/index.html#d0e2144
</a><br><br>But this rule is not working for me. If anyone know the logic behind the<br>rule, please explain me.<br><br>Example:<br><br>Imagine we have two classes - Student and Module. Module represents each of<br>the courses the Student attended for that semester, referenced by the List
<br>collection. At the end of the semester each Module has a score. If the<br>Student has a Module score below 40 then they will fail that semester - the<br>existential quantifier can be used used with the "less than 40" open
<br>proposition to check for the existence of a Module that is true for the<br>specified criteria.<br><br>public class Student {<br> private String name;<br> private List modules;<br><br> ...<br>}<br>public Class Module {
<br> private String name;<br> private String studentName;<br> private int score;<br>Java is Turing complete in that you can write code, among other things, to<br>iterate data structures to check for existence. The following should return
<br>a List of students who have failed the semester.<br><br>List failedStudents = new ArrayList();<br><br>for ( Iterator studentIter = students.iterator(); studentIter.hasNext() {<br> Student student = ( Student ) studentIter.next
();<br> for ( Iterator it = student.getModules.iterator(); it.hasNext(); ) {<br> Module module = ( Module ) it.next();<br> if ( module.getScore() < 40 ) {<br> failedStudents.add( student ) ;
<br> break;<br> }<br> }<br>}<br>Early SQL implementations where not Turing complete as they did not provide<br>quantifiers to asses the structure of data. However modern SQL engines allow<br>nesting of SQL which can be combined with keywords like 'exists' and 'in':
<br>The following query would return a set of Students who have failed the<br>semester.<br><br>select<br> *<br>from<br> Students s<br>where exists (<br> select<br> *<br> from<br> Modules m<br> where
<br> m.student_name = <a href="http://s.name">s.name</a> and<br> m.score < 40<br>)<br><br>rule<br> when<br> exists( $student : Student() && Module( student == $student, score <<br>40 ) )
<br><br>--<br>View this message in context: <a href="http://www.nabble.com/Logic-behind-the-Rule-tf3848998.html#a10902431">http://www.nabble.com/Logic-behind-the-Rule-tf3848998.html#a10902431</a><br>Sent from the drools - user mailing list archive at
<a href="http://Nabble.com">Nabble.com</a>.<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">
https://lists.jboss.org/mailman/listinfo/rules-users</a><br></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> Software Engineer - JBoss Rules Core Developer<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>