2

I can write:

update my_table
set xml = updateXML(xml, '/a/b', '1')
where document_id = 123

Now what if in the same update query I also want to set /a/c to 2 (in addition /a/b to 1)? I am tempted to write:

update my_table
set 
    xml = updateXML(xml, '/a/b', '1'),
    xml = updateXML(xml, '/a/c', '2')
where document_id = 123

But this give me a "ORA-00957: duplicate column name". Any suggestion on how to do this?

avernet
  • 30,895
  • 44
  • 126
  • 163

2 Answers2

5

The documentation indicates that the XPath string and expression can be repeated http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions205.htm#i1134878

so try

update my_table set xml = updateXML(xml, '/a/b', '1', '/a/c', '2') where document_id = 123

Gary Myers
  • 34,963
  • 3
  • 49
  • 74
1

update my_table set
xml = updateXML(xml, '/a/b/text()', '1','/a/c/text()','2') where document_id = 123

sth
  • 222,467
  • 53
  • 283
  • 367