Difference between revisions of "Client Module"
Jump to navigation
Jump to search
(Created page with "This XQuery Module contains functions to access remote BaseX server instances from XQuery. With this module, you can both execute commands and perform queries,...") |
|||
Line 27: | Line 27: | ||
| valign='top' | '''Errors''' | | 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/> | |<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/> | ||
+ | |- | ||
+ | | valign='top' | '''Examples''' | ||
+ | |The following query creates a new database <code>TEST</code> on a remote BaseX server: | ||
+ | <pre class="brush:xquery"> | ||
+ | let $c := client:connect('basex.server.org', 8080, 'admin', 'admin') | ||
+ | return client:execute($c, 'create database TEST') | ||
+ | </pre> | ||
|} | |} | ||
Revision as of 17:20, 25 May 2012
This 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 client
prefix, which is linked to the statically declared http://basex.org/modules/client
namespace.
Contents
Functions
client:connect
Signatures | client:connect($host as xs:string, $post as xs:integer, $user as xs:string, $password as xs:string) as xs:anyURI |
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 $host is the name of the database server, $host specifies the database host, and $user and $password represent the login data.
|
Errors | BXCL0001 is raised if a connection error occurs (e.g., if the addressed server is not available). |
client:execute
Signatures | client:execute($id as xs:anyURI, $command as xs:string) as xs:string
|
Summary | This function executes a database command and returns the result as string. The parameter $id contains the session id returned by client:connect(). The $command represents the database command string, which will be executed by the server.
|
Errors | BXCL0002 is raised if the specified session id is unknown. BXCL0003 is raised if an error occurs while executing the command. |
Examples | The following query creates a new database TEST on a remote BaseX server:
let $c := client:connect('basex.server.org', 8080, 'admin', 'admin') return client:execute($c, 'create database TEST') |
client:query
Signatures | client:query($id as xs:anyURI, $query as xs:string) as item()*
|
Summary | This function evaluates a query and returns the result as sequence. The parameter $id contains the session id returned by client:connect(), and $query represents the queru string, which will be evaluated by the server.
|
Errors | BXCL0002 is raised if the specified session id is unknown. BXCL0003 is raised if an error occurs while evaluating the query. |
client:close
Signatures | client:close($id as xs:anyURI) as empty-sequence()
|
Summary | This function closes a client session. $id specifies the session id.
|
Errors | FOSQ0001 is raised if an SQL exception occurs. FOSQ0002 is raised if a wrong connection handle is passed. |
Changelog
The module was introduced with Version 7.2.2.