Hi, I want to rebind the variables, but got the result that wasn't expected. How can I get the expected result without creating new processor instance? (When I use proc.query() and don't declare $var2 then got the expected result. But I have to declare $var2.) ---------- String query = "declare variable $var1 as xs:string external; " + "declare variable $var2 as xs:string := 'BBB'; " + "($var1, $var2)"; QueryProcessor proc = new QueryProcessor(query, new Context()); // "AAA BBB" proc.bind("var1", "AAA"); System.out.println(proc.execute()); //duplicate definition error of $var2 //proc.query(query); // "AAA BBB" not "CCC BBB" proc.bind("var1", "CCC"); System.out.println(proc.execute()); proc.close(); ---------- Thanks, Oda.
Hi Oda, query execution in BaseX includes various optimization steps, which might change the original quey plan. This can include the pre-evaluation of variable bindings, which will disallow repeated bindings. I'd recommend to create a new processor instance, which is fast enough in most scenarios we've encountered. Hope this helps, Christian ___________________________ Christian Grün, BaseX Uni KN, Box 188 78457 Konstanz, Germany http://www.basex.org On Thu, Jun 23, 2011 at 4:55 PM, Oda <0170003@gmail.com> wrote:
Hi,
I want to rebind the variables, but got the result that wasn't expected. How can I get the expected result without creating new processor instance? (When I use proc.query() and don't declare $var2 then got the expected result. But I have to declare $var2.)
---------- String query = "declare variable $var1 as xs:string external; " + "declare variable $var2 as xs:string := 'BBB'; " + "($var1, $var2)"; QueryProcessor proc = new QueryProcessor(query, new Context());
// "AAA BBB" proc.bind("var1", "AAA"); System.out.println(proc.execute());
//duplicate definition error of $var2 //proc.query(query);
// "AAA BBB" not "CCC BBB" proc.bind("var1", "CCC"); System.out.println(proc.execute());
proc.close(); ----------
Thanks,
Oda. _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Christian, thanks for your reply. I create a new processor instance. Oda. 2011/6/24 Christian Grün <christian.gruen@gmail.com>:
Hi Oda,
query execution in BaseX includes various optimization steps, which might change the original quey plan. This can include the pre-evaluation of variable bindings, which will disallow repeated bindings. I'd recommend to create a new processor instance, which is fast enough in most scenarios we've encountered.
Hope this helps, Christian ___________________________
Christian Grün, BaseX Uni KN, Box 188 78457 Konstanz, Germany http://www.basex.org
participants (2)
-
Christian Grün -
Oda