Need help with an XML function
Oracle 19c
I am trying to write a function that takes an xml column, an xml path, and a new value for that item and replaces the current value with the new value and spits out the updated xml. This is what I have so far but it doesn't work mostly due to my limited understanding to xmlquery and xquery. What am I doing wrong?
CREATE OR REPLACE FUNCTION XMLFUN( XCOL IN XMLTYPE, XNODE IN VARCHAR, NEWVAL VARCHAR )
RETURN XMLTYPE
IS
BEGIN
SELECT XMLQUERY(
'copy $t := . modify(
if( $t'||XNODE||') then
(
replace value of node $t'||XNODE||' with "'||NEWVAL||'"