Executes a SQL UPDATE statement, returning no result.

update($connection as javatype:java.sql.Connection, $table as xs:string, $predicate as xs:string, $changes as map(*)) ➔ item()?





A JDBC database connection established using sql:connect




The database table from which rows are to be updated




A SQL predicate identifying the rows to be updated




A map holding new values for the updated rows





Notes on the Saxon implementation

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


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

The $table argument names the database table to be updated, and the $predicate argument is a SQL predicate that selects which rows are to be updated. For each of these rows, new values for selected columns are taken from the $changes map.

The entries in the $changes map are (name, value) pairs, where the name is a column name in the table being updated, and the value is the new value for the column. The value should be an appropriate data type for the column (for example, xs:string for a VARCHAR column, xs:decimal for a DECIMAL column, etc).

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.


<saxon:do action="sql:update($connection, 'book', 'stock = 0', map{'out-of-print': true()}"/>