I have a simple query:
WITH xtbl AS (
SELECT XMLTYPE ('<a><b>1</b></a>') AS xcol
FROM DUAL
)
SELECT XMLQUERY ('copy $tmp := .
modify
insert node <c>2</c>
into $tmp/a/b
return $tmp'
PASSING xcol
RETURNING CONTENT) AS newxcol
FROM xtbl;
What I'm trying to do is to insert a node <c>
after <b>
inside the node <a>
but Oracle 12c is throwing this error:
ORA-19114: XPST0003 - error during parsing the XQuery expression:
LPX-00801: XQuery syntax error at 'EOF'
5 -
- ^
I want the output as:
NEWXCOL
-------------
<a>
<b>1</b>
<c>2</c/>
</a>
I have tried looking in Oracle Docs for a replacement of appendChildXML
and follow that example but only got the error.
I know it is very basic and I'm missing something obvious. Please help.
<c>2</c>
). Moreover, to get the desired result, the target path needs to be$tmp/a
not the$tmp/a/b
. – Fichu