Samuel Gobbo Almeida Samuel Gobbo Almeida - 3 months ago 25
Java Question

Execute a command block in XQuery in a java application

I am using a Xhive Database with java. In my Java application I need to call the same xquery function many times like this.

libDev.executeXQuery("import module namespace download = 'http://xquery.myxq.com.br/download' at 'http://localhost:8080/WebUpdate/xq/download.xq';
download:updateDeviceData('pc', '0040-A72D-4025')");

libDev.executeXQuery("import module namespace download = 'http://xquery.myxq.com.br/download' at 'http://localhost:8080/WebUpdate/xq/download.xq';
download:updateDeviceData('pc', '0040-A72D-4026')");


I want to make a command block like this and execute it only one time.
There are any way to do this in xquery?

libDev.executeXQuery("import module namespace download = 'http://xquery.myxq.com.br/download' at 'http://localhost:8080/WebUpdate/xq/download.xq';
download:updateDeviceData('pc', '0040-A72D-4025')
download:updateDeviceData('pc', '0040-A72D-4026')";


When I try to run this block I get this error:
com.xhive.error.xquery.XhiveXQueryParseException: query:3:1:XQUERY_PARSE_ERROR: no viable alternative at input 'download' (NCName) (XPST0003)

Answer

You need to wrap your expressions in a sequence constructor, i.e. (expr1, expr2)

libDev.executeXQuery("import module namespace download = 'http://xquery.myxq.com.br/download' at 'http://localhost:8080/WebUpdate/xq/download.xq';
(
download:updateDeviceData('pc', '0040-A72D-4025'),
download:updateDeviceData('pc', '0040-A72D-4026')
)";
Comments