2

I have xml document

<d>
  <r>a&lt;b</r>
</d>

and I want to update it to

<d>
  <r>a&lt;b or c&gt;d</r>
</d>

using updateXML statement.

Executing

select updateXML(xmltype('<d><r>a&lt;b</r></d>'),
                 '/d/r[1]/text()',
                 'a&lt;b or c&gt;d')
  from dual;

returns

<d>
  <r>a&amp;lt;b or c&amp;gt;d</r>
</d>

It is not good because of "&".

Executing

select updateXML(xmltype('<d><r>a&lt;b</r></d>'),
                 '/d/r[1]/text()',
                 'a<b or c>d')
  from dual;

throws

ORA-31067 XML nodes must be updated with valid nodes and of the same type.

How can I reach expected result?

EDIT: ORA-31067 is raised only in 10g database. It is correct query in 11g.

EDIT2: Error raised on 10.2.0.3 version and does not raised on 10.2.0.5. May by it was a bug?

Linus Caldwell
  • 10,908
  • 12
  • 46
  • 58
Kotodid
  • 879
  • 6
  • 18

1 Answers1

0

You can use this ugly workaround:

select dbms_xmlgen.convert(updateXML(xmltype('<d><r>a&lt;b</r></d>'),
                 '/d/r[1]/text()',
                 'a&lt;b or c&gt;d').getStringVal(), 1)
from dual;
A.B.Cade
  • 16,735
  • 1
  • 37
  • 53