Hi John,
all branches of your if expression must be updating, or return an empty sequence. In the latest snapshot [1], I’ve replaced the old error message with a more helpful one (“all expressions must be updating or return an empty sequence.”).
To come back to your query: The following query will be accepted:
for $c in doc('2012')/Docs/Doc/No/@n return if(doc('Data')/Docs/Doc[No/@n=$c]/Title/Name/text()) then insert node $c into doc('Data')/Docs else ()
The following query does the same:
for $c in doc('2012')/Docs/Doc/No/@n where doc('Data')/Docs/Doc[No/@n=$c]/Title/Name/text() return insert node $c into doc('Data')/Docs
If you want to return some textual output for all nodes that have not been updated, you can use db:output() [2]:
for $c in doc('2012')/Docs/Doc/No/@n return if(doc('Data')/Docs/Doc[No/@n=$c]/Title/Name/text()) then insert node $c into doc('Data')/Docs else db:output(<ld>{''}</l>)
Hope this helps, Christian
[1] http://files.basex.org/releases/latest/ [2] http://docs.basex.org/wiki/Database_Module#db:output