sql:execute

Executes a SQL statement, returning no result.

execute($connection as javatype:java.sql.Connection, $statement as xs:string) ➔ item()?

Arguments

 

$connection

javatype:java.sql.Connection

A JDBC database connection established using sql:connect

 

$statement

xs:string

The SQL statement to be executed

Result

item()?

Namespace

http://saxon.sf.net/sql

Saxon availability

Implemented since Saxon 9.9. Requires Saxon-PE or Saxon-EE. Available for Java only.

Notes on the Saxon implementation

Introduced in Saxon 9.9. Designed to supersede the extension instruction sql:execute. The saxon-sql-10.#.jar file, distributed alongside the main JAR file, must be added to the classpath when these SQL extension functions are used.

Details

The function executes a SQL statement, and returns no result.

If the statement is COMMIT WORK or ROLLBACK WORK (exactly as written) then it is intercepted and translated into a call on $connection?commit() or $connection?rollback_0().

Although the declared return type is item()?, the function always returns an empty sequence. The declared return type is designed to prevent the optimizer making unwarranted assumptions.

Because this function is executed for its side-effects, it is recommended to invoke it using the saxon:do extension instruction.

Example:

<saxon:do action="sql:execute($connection, 'DROP TABLE book')"/>