3,065 bytes added
, 17:17, 25 May 2012
This [[Module Library|XQuery Module]] contains functions to access remote BaseX server instances from XQuery. With this module, you can both execute commands and perform queries, and the result sets are returned as valid sequences using the correct XDM data types. All functions use the <code>client</code> prefix, which is linked to the statically declared <code>http://basex.org/modules/client</code> namespace.
=Functions=
==client:connect==
{|
|-
| valign='top' width='90' | '''Signatures'''
|<code><b>client:connect</b>($host as xs:string, $post as xs:integer, $user as xs:string, $password as xs:string) as xs:anyURI</code><br/ >
|-
| valign='top' | '''Summary'''
|This function establishes a connection to a remote BaseX server and creates a new client session. As a result, a session id is returned. The parameter <code>$host</code> is the name of the database server, <code>$host</code> specifies the database host, and <code>$user</code> and <code>$password</code> represent the login data.
|-
| valign='top' | '''Errors'''
|<b>BXCL0001</b> is raised if a connection error occurs (e.g., if the addressed server is not available).
|}
==client:execute==
{|
|-
| valign='top' width='90' | '''Signatures'''
|<code><b>client:execute</b>($id as xs:anyURI, $command as xs:string) as xs:string</code>
|-
| valign='top' | '''Summary'''
| This function executes a database command and returns the result as string. The parameter <code>$id</code> contains the session id returned by [[Client Module#client:connect|client:connect()]]. The <code>$command</code> represents the database command string, which will be executed by the server.
|-
| valign='top' | '''Errors'''
|<b>BXCL0002</b> is raised if the specified session id is unknown.<br/><b>BXCL0003</b> is raised if an error occurs while executing the command.<br/>
|}
==client:query==
{|
|-
| valign='top' width='90' | '''Signatures'''
|<code><b>client:query</b>($id as xs:anyURI, $query as xs:string) as item()*</code>
|-
| valign='top' | '''Summary'''
| This function evaluates a query and returns the result as sequence. The parameter <code>$id</code> contains the session id returned by [[Client Module#client:connect|client:connect()]], and <code>$query</code> represents the queru string, which will be evaluated by the server.
|-
| valign='top' | '''Errors'''
|<b>BXCL0002</b> is raised if the specified session id is unknown.<br/><b>BXCL0003</b> is raised if an error occurs while evaluating the query.<br/>
|}
==client:close==
{|
|-
| valign='top' width='90' | '''Signatures'''
|<code><b>client:close</b>($id as xs:anyURI) as empty-sequence()</code>
|-
| valign='top' | '''Summary'''
| This function closes a client session. <code>$id</code> specifies the session id.
|-
| valign='top' | '''Errors'''
|<b>[[XQuery Errors#SQL Functions Errors|FOSQ0001]]</b> is raised if an SQL exception occurs.<br/ >
<b>[[XQuery Errors#SQL Functions Errors|FOSQ0002]]</b> is raised if a wrong connection handle is passed.<br/ >
|}
=Changelog=
The module was introduced with Version 7.2.2.
[[Category:XQuery]]