Subject:Inserting and selecting data into DB by XQuery Author:Ivan Pedruzzi Date:23 Oct 2010 01:21 AM
Unfortunately an updating query cannot see its side effects because of the XQuery snapshot semantic.
You could try doing two queries, the first query does the insert and leave the PID empty and the second query updates the PID.
for $MYITEM in /root//item
,$record in collection("tm_m_taxdtls")//tm_m_taxdtls[key = $MYITEM/@id]
,$parent in collection("tm_m_taxdtls")/tm_m_taxdtls[key = $MYITEM/@pid]
ddtek:sql-update($record, "pid", $parent/id)