Changes

Jump to navigation Jump to search
316 bytes added ,  13:21, 24 May 2018
no edit summary
=Conventions=
 
{{Mark|Updated with Version 9.0}}:
All functions and errors in this module are assigned to the <code><nowiki>http://basex.org/modules/sql</nowiki></code> namespace, which is statically bound to the {{Code|sql}} prefix.<br/>
|-
| width='120' | '''Signatures'''
|{{Func|sql:connect|$url as xs:string|xs:anyURI}}<br/ >{{Func|sql:connect|$url as xs:string, $user as xs:string, $password as xs:string|xs:anyURI}}<br/ >{{Func|sql:connect|$url as xs:string, $user as xs:string, $password as xs:string, $options as map(xs:string, item()*)?|xs:anyURI}}<br/ >
|-
| '''Summary'''
|-
| '''Errors'''
|{{Error|error|#Errors}} an SQL exception occurs, e.g. missing JDBC driver or not existing relationoccurred when connecting to the database.
|-
| '''Examples'''
==sql:execute==
 
{{Mark|Updated with Version 9.0}}: Return update count for updating statements.
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|sql:execute|$id as xs:anyURI, $statement as xs:string|item()*}}<br/>{{Func|sql:execute|$id as xs:anyURI, $statement as xs:string, $options as map(*)?|item()*}}
|-
| '''Summary'''
* If an update statement was executed, the number of updated rows will be returned as integer.
* Otherwise, an XML representation of all results will be returned.
With {{Code|$options}}, the following parameter can be set:
* {{Code|timeout}}: query execution will be interrupted after the specified number of seconds.
|-
| '''Errors'''
|{{Error|error|#Errors}} an error occurred while executing SQL exception occurs, e.g. not existing relation is retrieved.<br/ >{{Error|id|#Errors}} the specified connection does not exist.<br/>{{Error|timeout|#Errors}} query execution exceeded timeout.<br/ >
|}
==sql:execute-prepared==
 
{{Mark|Updated with Version 9.0}}: Return update count for updating statements.
{| width='100%'
|-
| width='120' | '''Signatures'''
|{{Func|sql:execute-prepared|$id as xs:anyURI, $params as element(sql:parameters)|item()*}}<br/>{{Func|sql:execute-prepared|$id as xs:anyURI, $params as element(sql:parameters), $options as map(*)?|item()*}}
|-
| '''Summary'''
| This function executes a prepared statement:* with the specified {{Code|$id}}. The output format is identical to [[#sql:execute|sql:execute]].* The parameter {{Code|$id}} refers to the prepared statement.* The optional parameter {{Code|$params}} is an element {{Code|<sql:parameters/>}} representing the parameters for a prepared statement along with their types and values. The following schema shall be used:<br/ >
<pre class="brush:xquery">
element sql:parameters {
}?
</pre>
With {{Code|$options}}, the following parameter can be set:
* {{Code|timeout}}: query execution will be interrupted after the specified number of seconds.
|-
| '''Errors'''
|{{Error|attribute|#Errors}} an attribute different from {{Code|type}} and {{Code|null}} is set for a {{Code|<sql:parameter/>}} element.<br/ >{{Error|error|#Errors}} an error occurred while executing SQL exception occurs, e.g. not existing relation is retrieved.<br/ >{{Error|id|#Errors}} the specified connection does not exist.<br/ >{{Error|parameters|#Errors}} wrong number of no parameter type specified.<br/>{{CodeError|<sql:parameter/>timeout|#Errors}} elements, or parameter type is not specifiedquery execution exceeded timeout.<br/>{{Error|type|#Errors}} the value of a parameter cannot be converted to the specified format.
|}
|-
| '''Errors'''
|{{Error|error|#Errors}} an error occurred while executing SQL exception occurs.<br/ >{{Error|id|#Errors}} the specified connection does not exist.<br/ >
|}
|-
| '''Errors'''
|{{Error|error|#Errors}} an error occurred while executing SQL exception occurs.<br/ >{{Error|id|#Errors}} the specified connection does not exist.<br/ >
|}
|-
| '''Errors'''
|{{Error|error|#Errors}} an error occurred while executing SQL exception occurs.<br/ >{{Error|id|#Errors}} the specified connection does not exist.<br/ >
|}
|-
| '''Errors'''
|{{Error|error|#Errors}} an error occurred while executing SQL exception occurs.<br/ >{{Error|id|#Errors}} the specified connection does not exist.<br/ >
|}
=Errors=
 
{{Mark|Updated with Version 9.0}}:
{| class="wikitable" width="100%"
|-
|{{Code|parameters}}
|Wrong number of No parameter type specified.|-|{{Code|&lt;sql:parameter/&gt;timeout}} elements, or parameter type is not specified|Query execution exceeded timeout.
|-
|{{Code|type}}
;Version 9.0
* Updated: [[#sql:execute|sql:execute]], [[#sql:execute-prepared|sql:execute-prepared]]: Return update count for updating statements. {{Code|$options}} argument added.
* Updated: Connection ids are URIs now.
* Updated: error codes updated; errors now use the module namespace
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu