This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XQuery question - archiving queries

 
Phil Hu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey!
I am facing a really dificult problem concerning XQuery and I hope that you guys can help me!

The thing I would like to do is storing just executed queries as a string in a certain database. Moreover I would like to be able to reexecute these queries by a user defined function.

Now my questions:

- How can I get a just executed Query as a string to archive it somewhere in the database?
OR
- Is it able for the user to define the query as a string (and then see question 2, because the storing would be easy then)
- How can I execute a query which is stored in a node as a string? (e.g. "local:reExecuteQuery('/*/node/query')" when the query is stores in the node "query")


The solution I found is writing an own java-client that could implement these functionalities, but I think that this solution would be a bit of an overkill for this task ;)

I would be really happy I you helped me!

Thanks very much!
Cheers, Phil
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34669
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Phil,
Welcome to CodeRanch!

I thought XQuery queries were strings. Which means you can store them in a property file or a database or anywhere else. Can you elaborate on what you are thinking about that is more than this?
 
Phil Hu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey!
Thanks for the quick reply!

Well in my DBMS (let it be BaseX) I enter my query.. I want the query to be inserted into a normal node of another XML database because I want to archive the query.
The bigger problem arises when I want to tell the database to reexecute an already stored query..
I want to have a function that automatically executes a query when I call the function with a unique identification of that certain node.

This should look like follows:

<queries>
<id>1</id>
<query>QUERY IN FORM OF A STRING</query>
</queries>
<queries>
<id>2</id>
<query>QUERY IN FORM OF A STRING</query>
</queries>
...

So i want to call my custom function that automatically gets the string from the <query> node and executes the XQuery query stored in there.. Is there a command like execute($... as String)?

I hope I made it clear now ;)

Cheers, Phil


EDIT: It would be also interesting to create a hash out of the output to also add it to the "<queries>"- database ;) Do you know any approaches?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34669
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah. So there is no client - database directly. I haven't worked with XQuery on the database, but the question seems similar to "how do I get the database to remember SQL to run later." And the answer to that is a stored procedure or a stored function.

In fact, this FAQ talks about a future XQuery stored procedure language. The fact that they phrase it as plans makes me think anything that exists now is going to be database specific.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic