<br><font size=2 face="sans-serif">Dear All,</font>
<br>
<br><font size=2 face="sans-serif">I have created simple rule file and
created model in that rule file only</font>
<br>
<br><font size=2 color=#a00000 face="Courier New"><b>package</b></font><font size=2 face="Courier New">
com.sample</font>
<br><font size=2 face="Courier New">&nbsp;</font>
<br><font size=2 color=#a00000 face="Courier New"><b>import</b></font><font size=2 face="Courier New">
java.lang.String;</font>
<br>
<br><font size=2 color=#a00000 face="Courier New"><b>declare</b></font><font size=2 face="Courier New">
Rating</font>
<br><font size=2 face="Courier New">rate : </font><font size=2 color=#a00000 face="Courier New"><b>int</b></font>
<br><font size=2 face="Courier New">band : String</font>
<br><font size=2 face="Courier New">name : String</font>
<br><font size=2 color=#a00000 face="Courier New"><b>end</b></font>
<br>
<br><font size=2 color=#a00000 face="Courier New"><b>query</b></font><font size=2 face="Courier New">
</font><font size=2 color=#008000 face="Courier New">&quot;employee with
band E&quot;</font>
<br><font size=2 face="Courier New">ratg : Rating(band == </font><font size=2 color=#008000 face="Courier New">&quot;EBand&quot;</font><font size=2 face="Courier New">)</font>
<br><font size=2 color=#a00000 face="Courier New"><b>end</b></font>
<br><font size=2 face="Courier New">&nbsp;</font>
<br><font size=2 color=#a00000 face="Courier New"><b>rule</b></font><font size=2 face="Courier New">
</font><font size=2 color=#008000 face="Courier New">&quot;for E band&quot;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=#a00000 face="Courier New"><b>when</b></font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; r : Rating( rate == 1)</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=#a00000 face="Courier New"><b>then</b></font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; r.setBand(</font><font size=2 color=#008000 face="Courier New">&quot;EBand&quot;</font><font size=2 face="Courier New">);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; System.out.println( </font><font size=2 color=#008000 face="Courier New">&quot;in
E band&quot;</font><font size=2 face="Courier New"> ); </font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </font>
<br><font size=2 color=#a00000 face="Courier New"><b>end</b></font>
<br>
<br><font size=2 color=#a00000 face="Courier New"><b>rule</b></font><font size=2 face="Courier New">
</font><font size=2 color=#008000 face="Courier New">&quot;for D band&quot;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=#a00000 face="Courier New"><b>when</b></font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; r : Rating( rate == 2)</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=#a00000 face="Courier New"><b>then</b></font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; r.setBand(</font><font size=2 color=#008000 face="Courier New">&quot;EBand&quot;</font><font size=2 face="Courier New">);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; System.out.println( </font><font size=2 color=#008000 face="Courier New">&quot;in
E band&quot;</font><font size=2 face="Courier New"> ); </font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </font>
<br><font size=2 color=#a00000 face="Courier New"><b>end</b></font>
<br>
<br><font size=2 color=#a00000 face="Courier New"><b>rule</b></font><font size=2 face="Courier New">
</font><font size=2 color=#008000 face="Courier New">&quot;for C band&quot;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=#a00000 face="Courier New"><b>when</b></font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; r : Rating( rate == 3)</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=#a00000 face="Courier New"><b>then</b></font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; r.setBand(</font><font size=2 color=#008000 face="Courier New">&quot;EBand&quot;</font><font size=2 face="Courier New">);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; System.out.println( </font><font size=2 color=#008000 face="Courier New">&quot;in
E band&quot;</font><font size=2 face="Courier New"> ); </font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </font>
<br><font size=2 color=#a00000 face="Courier New"><b>end</b></font>
<br>
<br><font size=2 color=#a00000 face="Courier New"><b>rule</b></font><font size=2 face="Courier New">
</font><font size=2 color=#008000 face="Courier New">&quot;for B band&quot;</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=#a00000 face="Courier New"><b>when</b></font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; r : Rating( rate == 4)</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=#a00000 face="Courier New"><b>then</b></font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; r.setBand(</font><font size=2 color=#008000 face="Courier New">&quot;EBand&quot;</font><font size=2 face="Courier New">);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; System.out.println( </font><font size=2 color=#008000 face="Courier New">&quot;in
E band&quot;</font><font size=2 face="Courier New"> ); </font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </font>
<br><font size=2 color=#a00000 face="Courier New"><b>end</b></font>
<br>
<br>
<br><font size=2 face="sans-serif">At the end I want to know how many employees
have got E band and so have written query for it in the rule file .and
obtained the query results as below</font>
<br>
<br>
<br><font size=2 face="Courier New">FactType bandType = kbase.getFactType(
</font><font size=2 color=#4200ff face="Courier New">&quot;com.source&quot;</font><font size=2 face="Courier New">,
</font><font size=2 color=#4200ff face="Courier New">&quot;Rating&quot;</font><font size=2 face="Courier New">
);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QueryResults
results = ksession.getQueryResults(</font><font size=2 color=#4200ff face="Courier New">&quot;employee
with band E&quot;</font><font size=2 face="Courier New">);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.</font><font size=2 color=#0021bf face="Courier New"><i>out</i></font><font size=2 face="Courier New">.println(
</font><font size=2 color=#4200ff face="Courier New">&quot;we have &quot;</font><font size=2 face="Courier New">
+ results.size() + </font><font size=2 color=#4200ff face="Courier New">&quot;employee
with band E&quot;</font><font size=2 face="Courier New"> );</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.</font><font size=2 color=#0021bf face="Courier New"><i>out</i></font><font size=2 face="Courier New">.println(
</font><font size=2 color=#4200ff face="Courier New">&quot;employee with
band E:&quot;</font><font size=2 face="Courier New"> );</font>
<br>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </font><font size=2 color=#820040 face="Courier New"><b>for</b></font><font size=2 face="Courier New">
(<u>Iterator</u> i = results.iterator(); i.hasNext();) {</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; QueryResultsRow row = (QueryResultsRow)i.next();</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; Object ratg = row.get(</font><font size=2 color=#4200ff face="Courier New">&quot;rating&quot;</font><font size=2 face="Courier New">);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; String name = (String) bandType.get( ratg, </font><font size=2 color=#4200ff face="Courier New">&quot;name&quot;</font><font size=2 face="Courier New">
);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; System.</font><font size=2 color=#0021bf face="Courier New"><i>out</i></font><font size=2 face="Courier New">.println(name);</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</font>
<br>
<br>
<br><font size=2 face="sans-serif">But am getting the result of query as
0 records.</font>
<br>
<br>
<br><font size=2 face="sans-serif">i am inserting objects one by one (
this for testing just purpose ) to learn how query works.</font>
<br>
<br>
<br><font size=2 face="sans-serif">Can someone plz point out what is wrong.Its
Urgent ................</font>
<br>
<br>
<br><font size=2 face="sans-serif">Thanks in advance.<br>
Nilu</font><pre>=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you


</pre>