dbTalk Databases Forums  

Xquery Related Question

comp.databases.berkeley-db comp.databases.berkeley-db


Discuss Xquery Related Question in the comp.databases.berkeley-db forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
sandesh
 
Posts: n/a

Default Xquery Related Question - 12-13-2005 , 08:57 AM






Hi,
I have one question regarding XQuery.
Is it possible to construct the Xquery expression dynamically?
Eg:
collection("collectionName")/root/node[@value > 1000]

Here the condition Greater Than or Less Than Depends on User input, So
what I want is,

I would like to have this query in a file which I read during run
time and dynamically set the condition.


Please let me know if it is possible to do and If yes please give a
small example

regards
Sandesh


Reply With Quote
  #2  
Old   
George Feinberg
 
Posts: n/a

Default Re: Xquery Related Question - 12-13-2005 , 02:56 PM







sandesh wrote:
Quote:
Hi,
I have one question regarding XQuery.
Is it possible to construct the Xquery expression dynamically?
Eg:
collection("collectionName")/root/node[@value > 1000]

Here the condition Greater Than or Less Than Depends on User input, So
what I want is,

I would like to have this query in a file which I read during run
time and dynamically set the condition.


Please let me know if it is possible to do and If yes please give a
small example
Sandesh,

You can do this with a conditional expression in your query. For
example,
you can create a string variable, "op" in the BDB XML query context,
and pass it to
the query, and your query would look like this:
"let $res := (if ($op = 'gt') then
collection('collectionName')/root/node[@value > 1000] else
collection('collectionName')/root/node[@value < 1000]) return $res"

There are other ways to construct such a conditional, including
probably doing it
exclusively with XPath2 constructs.

Regards,

George



Reply With Quote
  #3  
Old   
sandesh
 
Posts: n/a

Default Re: Xquery Related Question - 12-13-2005 , 09:59 PM



George,
Thanks for the reply.
Even I thought of doing it this way but some how I am not convinced
to do it this way because currently I have around 20 such variables and
it would grow drastically along with different conditions and I
thought if XQuery supports this(i.e dynamically setting the conditions)
I can make use of it, but if there is no other way I have to do it
like this

Regards
Sandesh


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.