You can do that with a few lines of code to compile and deploy a query.
You pass in the session, the builder and the query text:
dq = new DynamicQuery( StatefulKnowledgeSession kSession,
KnowledgeBuilder kBuilder,
String queryString )
and you call it, passing in the parameters you might have:
QueryResults results = dq.execute(...);
And you could add a remove() method.
-W
On 27/06/2012, jpullmann <jaroslav.pullmann(a)fit.fraunhofer.de> wrote:
Hello,
is there any support for ad-hoc queries in Drools or are there plans to
introduce this feature ?
Being part of the rule base queries are executed in the manner of
prepared
statements.
To execute dynamic query patterns I currently create, add and remove a KB
package containing
the query. It would be great to have a dedicated/optimized utility method
in Drools, that accepts
a string pattern and returns QueryResults, like
WorkingMemory#getQueryResults. There were similar
requests earlier [1], [2], but they were not responded with regard to
dynamic queries.
[1]
http://drools.46999.n3.nabble.com/Creating-ad-hoc-queries-td51522.html
[2]
http://drools.46999.n3.nabble.com/Inspecting-Working-Memory-td52382.html
Best regards
Jaro
--
View this message in context:
http://drools.46999.n3.nabble.com/Support-for-dynamic-ad-hoc-queries-in-D...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users