Changes

Jump to navigation Jump to search
2 bytes added ,  16:45, 10 August 2022
<syntaxhighlight lang="xquery">
(: Retrieve documents from database :)
let $client-id := client:connect('localhost', 1984, 'admin', 'admin...')
let $docs := client:query($client-id, 'db:get("conflict")')
(: Create database with same name :)
|- valign="top"
| width='120' | '''Signatures'''
|{{Func|client:connect|$host as xs:string, $port as xs:integer, $user username as xs:string, $password as xs:string|xs:anyURI}}<br/ >
|- valign="top"
|'''Summary'''
|This function establishes a connection to a remote BaseX server, creates a new client session, and returns a session id. The parameter {{Code|$host}} is the name of the database server, {{Code|$port}} specifies the server port, and {{Code|$userusername}} and {{Code|$password}} represent the login data.
|- valign="top"
|'''Errors'''
|The following query creates a new database {{Code|TEST}} on a remote BaseX server:
<syntaxhighlight lang="xquery">
client:connect('basex.server.org', 8080, 'admin', 'admin...') !
client:execute(., 'create database TEST')
</syntaxhighlight>
|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}}:
<syntaxhighlight lang="xquery">
let $c := client:connect('localhost', 1984, 'admin', 'admin...')
return client:query($c, "declare variable $n external; $n * 2", map { 'n': 123 })
</syntaxhighlight>
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu