Binding a variable to a sequence
Tuesday, 14 April 2020 · 2 messages
BE
Ben Engbers14 Apr 2020 18:14 #
Hi,
I am still trying to improve my R-package and at the moment I am working (again) on the 'Binding' command.
I have added this XML to a database:
<book title="XQuery" author="Walmsley"/>
<book title="Advanced R" author="Wickham"/>
This query:
for $t in collection("TestDB/Books")/book
where $t/@author = "Walmsley"
return $t/@title/string()returns:
XQuery
My command:
Bind(Query_3, "$name", list("Walmsley", "Wickham"))
sends the following byte-sequence to the server:
57 61 6c 6d 73 6c 65 79 01 57 69 63 6b 68 61 6d 00 00
And this sequence is accepted by the server.
In Query_3, I try to bind $name to the sequence:
declare variable $name external;
for $t in collection('TestDB/Books')/book
where $t/@author = $name
return $t/@title/string()The query is executed but no results are given. (I had expected that it would return the sequence {"XQuery", "Advanced R"}
How should I correct the query-statement?
Cheers,
Ben
CG
Christian Grün14 Apr 2020 18:18 #
Hi Ben,
Have you already tried if your server request works with the standard Java binding?
Best,
Christian
Quoted text · Ben Engbers · 39 lines
On Tue, Apr 14, 2020 at 6:15 PM Ben Engbers <Ben.Engbers at be-logical.nl> wrote: > > Hi, > > I am still trying to improve my R-package and at the moment I am working > (again) on the 'Binding' command. > > I have added this XML to a database: > <book title="XQuery" author="Walmsley"/> > <book title="Advanced R" author="Wickham"/> > > This query: > for $t in collection("TestDB/Books")/book > where $t/@author = "Walmsley" > return $t/@title/string() > > returns: > XQuery > > My command: > Bind(Query_3, "$name", list("Walmsley", "Wickham")) > > sends the following byte-sequence to the server: > 57 61 6c 6d 73 6c 65 79 01 57 69 63 6b 68 61 6d 00 00 > > And this sequence is accepted by the server. > In Query_3, I try to bind $name to the sequence: > declare variable $name external; > for $t in collection('TestDB/Books')/book > where $t/@author = $name > return $t/@title/string() > > The query is executed but no results are given. (I had expected that it > would return the sequence {"XQuery", "Advanced R"} > > How should I correct the query-statement? > > Cheers, > Ben
Written for BaseX 9.3. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery