Quantcast
Channel: Oracle, MySQL, Sybase, Informix and other databases
Viewing all articles
Browse latest Browse all 1350

oracle xmltype question

$
0
0

i have a table with 2 column, 1st is ID and 2nd is xml data with data type 'xmltype'

-------------------------------------

id         xmldata

1          <row id='1'><a1>name</a1><a2>address1</a2><a3>tel1</a3><a3 m='2'>20181231</a3><a3 m='3'>date3</a3></row>

2          <row id='2'><a1>name2</a1><a2>address2</a2><a3>tel2</a3><a3 m='2'>20181111</a3><a3 m='3'>date4</a3></row>

3          <row id='3'><a1>name3</a1><a2>address3</a2><a3>tel3</a3><a3 m='2'>20181231</a3><a3 m='3'>date5</a3></row>

-------------------------------------

now i would like to select all the records node <a3 m='2'> = '20181231' to update to '20181230'

----------- expected result

id         xmldata

1          <row id='1'><a1>name</a1><a2>address1</a2><a3>tel1</a3><a3 m='2'>20181230</a3><a3 m='3'>date3</a3></row>

2          <row id='2'><a1>name2</a1><a2>address2</a2><a3>tel2</a3><a3 m='2'>20181111</a3><a3 m='3'>date4</a3></row>

3          <row id='3'><a1>name3</a1><a2>address3</a2><a3>tel3</a3><a3 m='2'>20181230</a3><a3 m='3'>date5</a3></row>

-----------

my sql is as below it seems failure to return my expected result

update customer set xmldata= updatexml( xmldata, '/row/a3[m='2'], '20181230') where extractvalue( xmldata, 'row/a3[m='2']')='2081231'

--------------------------------------

now i would like to select all the records node <a3 m='2'> = '20181231' to update to '20181230'

how can i prepare a update sql to do that? any sql example? as my sql above can't return my expected result.


Viewing all articles
Browse latest Browse all 1350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>