Hi,

I have a question regarding the use the XML:DB API with Compiled Expressions
and Variables

I want to execute the following query a lot of times:
let $col :=
document("Indentifier.xml","myCollection")/IdentifierList/Identifiers/identifi...@iid
= $IID] return $col

So I though I would compile the Expression the first time I use it and then
reuse it, something like

//Get a XQUery Service
XQueryService service = (XQueryService)
session.getCollections().systemControlCollection.getService(XQueryService.SERVICE_NAME,
"1.0");
//The expressions variable is a map of String -> CompiledExpression
CompiledExpression currentExpression;
if (!expressions.containsKey(GET_MRI_FROM_IID))
{
service.declareVariable("IID", IID);
String query = "let $col :=
document(\"Indentifier.xml\",\"myCollection\")/IdentifierList/Identifiers/identifi...@iid
= $IID] return $col";
currentExpression = service.compile(query);
expressions.put(GET_MRI_FROM_IID, currentExpression);
}
else
{
currentExpression = expressions.get(GET_MRI_FROM_IID);
currentExpression.reset();
service.declareVariable("IID", IID);
}

The ideia is, if it's the first time the query is run, it's compiled and
kept in the map, if it's the second (or more) time I reuse it from
the map and reset it declaring the variable (IID) again.

The problem I'm having is that the variable is not reset and the second time
it runs, it's using the previous value for the variable ($IID)

Am I Doing something wrong?

Also, Is it possible to used declared variables in expressions inside a
Sedna Update Statement (and filling the value with XML:DB API, using the
declare variable statement)?
I tried but not with much luck, but I've never seen an example so I can be
doing something wrong.

Thanks in advance to anyone who tries to help :)


-- 
Pedro Pereira
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Sedna-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sedna-discussion

Reply via email to