The query is treated just like a pattern. ? indicates whether the query should be materialised or not. In general if you aren&#39;t sure, then don&#39;t include the ? and let it materialise.<br><br>The queries do not return any results, they are not functions. Like patterns the resuls are returned from out variable bindings in the parameters. The work in the same way that prolog predicates work, and you can find tuns of literatore on that.<br>
<br>see  2.2.2.8 has a fair overview of this:<br><a href="http://docs.jboss.org/drools/release/5.3.0.Final/droolsjbpm-introduction-docs/html/releaseNotes.html#d0e50">http://docs.jboss.org/drools/release/5.3.0.Final/droolsjbpm-introduction-docs/html/releaseNotes.html#d0e50</a><br>
<br>see 5.9 here:<br><a href="http://docs.jboss.org/drools/release/5.3.0.Final/drools-expert-docs/html/ch05.html#d0e6233">http://docs.jboss.org/drools/release/5.3.0.Final/drools-expert-docs/html/ch05.html#d0e6233</a><br><br>
This should work for your example:<br>query query1(List $facts)<br>
    $facts := List() from collect( Fact( name == &quot;name1&quot; ) )<br>
end<br>
<br>
query query2<br>   query1($l;)<br>
end<br><br>The above $l should join with the results of query1, as it&#39;s unbound and thus an output variable.<br><br>Mark<br><br><div class="gmail_quote">On Mon, Nov 28, 2011 at 12:41 PM, Syargey <span dir="ltr">&lt;<a href="mailto:Syargey@tut.by">Syargey@tut.by</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I read in Drools guide, that queries can now call other queries.<br>
<br>
But the guide doesn&#39;t give much details, mostly paying attention to a rather<br>
specific case.<br>
<br>
I have two queries having common parts and try to figure out how to  get rid<br>
of duplicate code.<br>
<br>
Here is the simplified form of queries I&#39;d like to have:<br>
---------<br>
<br>
query query1<br>
    $facts: List()<br>
        from collect( Fact( name == &quot;name1&quot; ) )<br>
end<br>
<br>
query query2<br>
    $l: List()<br>
        from collect( Fact( value == &quot;1&quot; ) from ?query1() )<br>
end<br>
<br>
---------<br>
<br>
query2 syntax is invalid and and it is not clear for me how $facts from<br>
query1 can be accessed in query2.<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Call-query-from-other-query-tp3542082p3542082.html" target="_blank">http://drools.46999.n3.nabble.com/Call-query-from-other-query-tp3542082p3542082.html</a><br>

Sent from the Drools: User forum 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><br>
</font></span></blockquote></div><br>