XQuery Function Documentation

Search and Browse

http://exist-db.org/xquery/sql

java:org.exist.xquery.modules.sql.SQLModule

A module for performing SQL queries against Databases, returning XML representations of the result sets.

sql:close-connection

sql:close-connection($connection-handle as xs:long) as xs:boolean

Closes a connection to a SQL Database, or if the connection was taken from a connection pool then it is returned to the pool

Parameters:
$connection-handlean xs:long representing the connection handle
Returns:
xs:boolean : true if the connection was closed, false if there was no such connection

sql:execute

sql:execute($connection-handle as xs:long, $sql-statement as xs:string, $make-node-from-column-name as xs:boolean) as element()?

Executes a prepared SQL statement against a SQL db.

Parameters:
$connection-handleThe connection handle
$sql-statementThe SQL statement
$make-node-from-column-nameThe flag that indicates whether the xml nodes should be formed from the column names (in this mode a space in a Column Name will be replaced by an underscore!)
Returns:
element()? : the results

sql:execute

sql:execute($connection-handle as xs:long, $statement-handle as xs:long, $parameters as element()?, $make-node-from-column-name as xs:boolean) as element()?

Executes a prepared SQL statement against a SQL db.

Parameters:
$connection-handleThe connection handle
$statement-handleThe prepared statement handle
$parameters?Parameters for the prepared statement. e.g. <sql:parameters><sql:param sql:type="long">1234</sql:param><sql:param sql:type="varchar"><sql:null/></sql:param></sql:parameters>
$make-node-from-column-nameThe flag that indicates whether the xml nodes should be formed from the column names (in this mode a space in a Column Name will be replaced by an underscore!)
Returns:
element()? : the results

sql:execute

sql:execute($connection-handle as xs:long, $sql-statement as xs:string, $make-node-from-column-name as xs:boolean, $ns-uri as xs:string, $ns-prefix as xs:string) as element()?

Executes a prepared SQL statement against a SQL db.

Parameters:
$connection-handleThe connection handle
$sql-statementThe SQL statement
$make-node-from-column-nameThe flag that indicates whether the xml nodes should be formed from the column names (in this mode a space in a Column Name will be replaced by an underscore!)
$ns-uriThe uri of the result namespace.
$ns-prefixThe prefix of the result namespace.
Returns:
element()? : the results

sql:execute

sql:execute($connection-handle as xs:long, $statement-handle as xs:long, $parameters as element()?, $make-node-from-column-name as xs:boolean, $ns-uri as xs:string, $ns-prefix as xs:string) as element()?

Executes a prepared SQL statement against a SQL db.

Parameters:
$connection-handleThe connection handle
$statement-handleThe prepared statement handle
$parameters?Parameters for the prepared statement. e.g. <sql:parameters><sql:param sql:type="long">1234</sql:param><sql:param sql:type="varchar"><sql:null/></sql:param></sql:parameters>
$make-node-from-column-nameThe flag that indicates whether the xml nodes should be formed from the column names (in this mode a space in a Column Name will be replaced by an underscore!)
$ns-uriThe uri of the result namespace.
$ns-prefixThe prefix of the result namespace.
Returns:
element()? : the results

sql:get-connection

sql:get-connection($driver-classname as xs:string, $url as xs:string) as xs:long?

Opens a connection to a SQL Database

Parameters:
$driver-classnameThe JDBC driver classname
$urlThe JDBC connection URL
Returns:
xs:long? : an xs:long representing the connection handle. The connection will be closed (or returned to the pool) automatically when the calling XQuery finishes execution, if you need to return it sooner you can call sql:close-connection#1

sql:get-connection

sql:get-connection($driver-classname as xs:string, $url as xs:string, $properties as element()?) as xs:long?

Opens a connection to a SQL Database

Parameters:
$driver-classnameThe JDBC driver classname
$urlThe JDBC connection URL
$properties?The JDBC database connection properties in the form <properties><property name="" value=""/></properties>.
Returns:
xs:long? : an xs:long representing the connection handle. The connection will be closed (or returned to the pool) automatically when the calling XQuery finishes execution, if you need to return it sooner you can call sql:close-connection#1

sql:get-connection

sql:get-connection($driver-classname as xs:string, $url as xs:string, $username as xs:string, $password as xs:string) as xs:long?

Opens a connection to a SQL Database

Parameters:
$driver-classnameThe JDBC driver classname
$urlThe JDBC connection URL
$usernameThe SQL database username
$passwordThe SQL database password
Returns:
xs:long? : an xs:long representing the connection handle. The connection will be closed (or returned to the pool) automatically when the calling XQuery finishes execution, if you need to return it sooner you can call sql:close-connection#1

sql:get-connection-from-pool

sql:get-connection-from-pool($pool-name as xs:string) as xs:long?

Retrieves a connection to a SQL Database from a connection pool

Parameters:
$pool-nameThe connection pool name (as configured in conf.xml)
Returns:
xs:long? : an xs:long representing the connection handle. The connection will be closed (or returned to the pool) automatically when the calling XQuery finishes execution, if you need to return it sooner you can call sql:close-connection#1

sql:get-connection-from-pool

sql:get-connection-from-pool($pool-name as xs:string, $username as xs:string, $password as xs:string) as xs:long?

Retrieves a connection to a SQL Database from a connection pool

Parameters:
$pool-nameThe connection pool name (as configured in conf.xml)
$usernameThe SQL database username
$passwordThe SQL database password
Returns:
xs:long? : an xs:long representing the connection handle. The connection will be closed (or returned to the pool) automatically when the calling XQuery finishes execution, if you need to return it sooner you can call sql:close-connection#1

sql:get-jndi-connection

sql:get-jndi-connection($jndi-name as xs:string) as xs:long?

Opens a connection to a SQL Database.

Parameters:
$jndi-nameThe JNDI name
Returns:
xs:long? : an xs:long representing the connection handle

sql:get-jndi-connection

sql:get-jndi-connection($jndi-name as xs:string, $username as xs:string, $password as xs:string) as xs:long?

Opens a connection to a SQL Database.

Parameters:
$jndi-nameThe JNDI name
$usernameThe username
$passwordThe password
Returns:
xs:long? : an xs:long representing the connection handle

sql:prepare

sql:prepare($handle as xs:long, $sql-statement as xs:string) as xs:long?

Prepares a SQL statement against a SQL db using the connection indicated by the connection handle.

Parameters:
$handleThe connection handle
$sql-statementThe SQL statement
Returns:
xs:long? : an xs:long representing the statement handle