Changes

Jump to navigation Jump to search
60 bytes removed ,  18:30, 1 December 2023
m
Text replacement - "<syntaxhighlight lang="xquery">" to "<pre lang='xquery'>"
| '''Examples'''
|Connects to an SQL Server and sets autocommit to {{Code|true}}:
<syntaxhighlight pre lang="'xquery"'>
sql:connect('dbc:sqlserver://DBServer', map { 'autocommit': true() })
</syntaxhighlight>
| '''Summary'''
| This function executes a prepared statement with the specified {{Code|$id}}. The output format is identical to {{Function||sql:execute}}. 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/ >
<syntaxhighlight pre lang="'xquery"'>
element sql:parameters {
element sql:parameter {
A simple select statement can be executed as follows:
<syntaxhighlight pre lang="'xquery"'>
let $id := sql:connect("jdbc:postgresql://localhost:5432/coffeehouse")
return sql:execute($id, "SELECT * FROM coffees WHERE price < 10")
A prepared select statement can be executed in the following way:
<syntaxhighlight pre lang="'xquery"'>
(: Establish a connection :)
let $conn := sql:connect("jdbc:postgresql://localhost:5432/coffeehouse")
The following expression demonstrates how SQLite can be addressed with the [https://bitbucket.org/xerial/sqlite-jdbc/ Xerial SQLite JDBC driver]:
<syntaxhighlight pre lang="'xquery"'>
(: Initialize driver :)
sql:init("org.sqlite.JDBC"),
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu