wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes XQuery question - archiving queries Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XQuery question - archiving queries" Watch "XQuery question - archiving queries" New topic
Author

XQuery question - archiving queries

Phil Hu
Greenhorn

Joined: Oct 15, 2013
Posts: 4
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30057
    
149

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?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Phil Hu
Greenhorn

Joined: Oct 15, 2013
Posts: 4
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30057
    
149

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: XQuery question - archiving queries
 
Similar Threads
Get a function result
Newbie - web service design assistance needed
How to handle error from CallableStatement??
XQuery Function Examples
Miscellaneous JDBC Queries