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-handle an 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-handle The connection handle
$sql-statement The SQL statement
$make-node-from-column-name The 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-handle The connection handle
$statement-handle The 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-name The 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: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-classname The JDBC driver classname
$url The 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-classname The JDBC driver classname
$url The 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-classname The JDBC driver classname
$url The JDBC connection URL
$username The SQL database username
$password The 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-name The 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-name The connection pool name (as configured in conf.xml)
$username The SQL database username
$password The 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-name The 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-name The JNDI name
$username The username
$password The 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:
$handle The connection handle
$sql-statement The SQL statement
Returns:
xs:long? : an xs:long representing the statement handle