XQuery works a bit different: on the first line you send the options, then after that the query follows. An example of JdbcClient using it: % JdbcClient -lxquery -p45789 -Xdebug Connection warning: database specifier not supported on this server (mserver_xquery), protocol version 4 Welcome to the MonetDB interactive JDBC terminal! Type \q to quit, \h for a list of available commands auto commit mode: on monetdb-> 1 + <foo>1</foo>; +--------------------------------------------------------------+ | xml | +==============================================================+ | 2.000000 | +--------------------------------------------------------------+ 1 row monetdb-> % cat monet_1120328168519.log RX 1120328168521: 19 RX 1120328168521: ::mserver_xquery:4 TX 1120328168522: monetdb:monetdb:xquery:blocked TX 1120328168522: � RX 1120328168523: � RX 1120328168523: new block: 3 bytes RX 1120328168563: read chunk: 3 bytes, left: 0 bytes RX 1120328168564: TX 1120328171821: write block: 29 bytes TX 1120328171821: xml-seq-mapi 1 + <foo>1</foo> TX 1120328171822: zero block (flush) RX 1120328171822: zero block (flush) RX 1120328171914: new block: 151 bytes RX 1120328171914: read chunk: 151 bytes, left: 0 bytes RX 1120328171914: #- # 3 # querytype # xquery_result, xquery_result # table_name # xml # name # varchar # type # 60 # length # 1 # tuplecount # 1 # id [ "2.000000" ] The important aspect for you here is the part: TX 1120328171821: xml-seq-mapi 1 + <foo>1</foo> the newline is what separates the options from the actual query. You probably want to use another query mode though, because xml-seq-mapi generates the headers and tuple format, so the JDBC driver can deal with it. Martijn Faassen wrote:
Hi there,
I'm trying to figure out how to use mapi to do an xquery. I have been able to shred documents (using MIL), but mapi with xquery is giving me trouble.
Looking at the implementation of MapiClient, I see the following piece of code which appears relevant:
/* xquery options are passed via the command string (becomes first line of query) */ char *c = command ? command : XQuerydefaultMode; char *t = strstr(c, "timing-") ? "" : mark ? "timing-" : ""; char *d = strstr(c, "debug-") ? "" : trace ? "debug-" : ""; char *m = strstr(c, "-mapi") ? "" : "-mapi";
command = (char*) malloc(strlen(c) + 20); sprintf(command, "%s%s%s%s\n", t, d, c, m);
as well as this code:
if (command) { /* special code for XQuery: prepend command to query */ hdl = mapi_query_prep(mid); CHECK_RESULT(mid, hdl, buf, break); mapi_query_part(hdl, command, strlen(command));
what exactly is going on here? The logic is rather opaque... Is there some minimal code example somewhere out there that shows how to do an xquery using mapi?
Regards,
Martijn
------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users