Changes

Jump to navigation Jump to search
4 bytes removed ,  15:29, 27 February 2020
no edit summary
Please note that the client module should always be used to address independent BaseX server instances. You can create deadlocks if you evaluate a query with a server instance, and if you are addressing the same server instance in your query. See the following example:
<pre classsyntaxhighlight lang="brush:xquery">
(: Retrieve documents from database :)
let $client-id := client:connect('localhost', 1984, 'admin', 'admin')
(: Create database with same name :)
return db:create('conflict', $docs, $docs ! db:path(.))
</presyntaxhighlight>
The read-only query cannot be processed, because the <code>conflict</code> database is currently write-locked by the main query. See [[Transaction Management]] for more background information.
=Conventions=
 
{{Mark|Updated with Version 9.0}}:
All functions and errors in this module are assigned to the <code><nowiki>http://basex.org/modules/client</nowiki></code> namespace, which is statically bound to the {{Code|client}} prefix.<br/>
| '''Examples'''
|The following query creates a new database {{Code|TEST}} on a remote BaseX server:
<pre classsyntaxhighlight lang="brush:xquery">
client:connect('basex.server.org', 8080, 'admin', 'admin') !
client:execute(., 'create database TEST')
</presyntaxhighlight>
|}
| '''Examples'''
|The following query sends a query on a local server instance, binds the integer {{Code|123}} to the variable {{Code|$n}} and returns {{Code|246}}:
<pre classsyntaxhighlight lang="brush:xquery">
let $c := client:connect('localhost', 1984, 'admin', 'admin')
return client:query($c, "declare variable $n external; $n * 2", map { 'n': 123 })
</presyntaxhighlight>
The following query performs a query on a first server, the results of which are passed on to a second server:
<pre classsyntaxhighlight lang="brush:xquery">
let $c1 := client:connect('basex1.server.org', 8080, 'jack', 'C0S19tt2X')
let $c2 := client:connect('basex2.server.org', 8080, 'john', '465wFHe26')
for $it in client:query($c1, '1 to 10')
return client:query($c2, $it || '* 2')
</presyntaxhighlight>
|}
=Errors=
 
{{Mark|Updated with Version 9.0}}:
{| class="wikitable" width="100%"
;Version 9.0
* Updated: error codes updatesupdated; errors now use the module namespace
;Version 8.0
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu