Learn XQuery |
Home:Learn XQuery:XQuery Examples:XQuery Updates:Insert, Update, Delete ddtek:sql - Insert, Update, DeleteLearn to: insert a single record in a database table, update records in a database table, and delete records in a database table. ddtek:sql-insertThis built-in function inserts a single record in a database table. The syntax is:
declare updating function ddtek:sql-insert(
table as xs:string,
column as xs:string,
value as item()*,
...) external;
where:
The following example inserts a new record with three columns into the holdings table. The columns and their values are ddtek:sql-updateThis built-in function updates records in a database table. The syntax is:
declare updating function ddtek:sql-update(
row as element()*,
column as xs:string,
value as item()*,
...) external;
where: row identifies the records in the database table to update. Each item in the sequence must be a row element of the database table returned by a previous fn:collection() call. column is the column of the database table to update. value is the new value for the specified column. column and value are a pair in a variable argument list. If column is specified without value, an error is raised. The following example updates a record in the holdings table, the record where the userid column equals Minollo and the stockticker column equals PRGS. In this record, the shares column is updated to 500.
ddtek:sql-update(
collection("holdings")/holdings[userid="Minollo" and stockticker="PRGS"],
"shares", 500)
ddtek:sql-deleteThis built-in function deletes records in a database table. The syntax is:
declare updating function ddtek:sql-delete(
row as element()*) external;
where: row identifies the records to be deleted. Each item in the sequence must be a row element of the database table returned by a previous fn:collection() call. The following example deletes all of the records in the holdings database table where the userid column equals Minollo.
ddtek:sql-delete(collection("holdings")/holdings[userid = "Minollo"])
|





