Hello, I am playing with XQUF in BaseX ann I encountered following problems. 1) XQuery is functional language and updating function can return empty sequence. How can I count and return result how many nodes was inserted or updated ? Example: declare %private %updating function cfv:upsertVehicles ($vehicles as node()*) as empty-sequence() { let $db := db:open("db")/cars for $v in $vehicles let $dbVehicle := $db/car[vin = $v/vin] return if (not(exists($dbVehicle))) then (insert node $v as last into $db) else if (exists($dbVehicle)) then (replace node $dbVehicle with $v) else () }; I have similar problem with error handling. How can I catch and return any error. Regards Bogdan Bogucki