简体   繁体   中英

How can I update a specific node in a xml column

I have the following data stored in my table [fixed_width_export_specification_t][specification_xml]'

<fixed_width_metadata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <fixed_width_metadata_row>
    <rowtype>sys_header</rowtype>
    <dbname>sys_nm_label</dbname>
    <width>56</width>
    <fillleftright>right</fillleftright>
  </fixed_width_metadata_row>
  <fixed_width_metadata_row>
    <rowtype>remit1</rowtype>
    <dbname>remit_column1</dbname>
    <width>32</width>
    <fillleftright>right</fillleftright>
  </fixed_width_metadata_row>
</fixed_width_metadata>

I want to update the width where rowtype is equal to remit1 and dbname is equal to remit_column1 from 32 to 61

I played around with the diffrent xqueries to na avail. I don't know how to isolate the element that I want namely width and to then subsequenly update its value.

update fixed_width_export_specification_t
set specification_xml.modify
  ('replace value of (/fixed_width_metadata/
                        fixed_width_metadata_row
                         [rowtype = "remit1" and dbname = "remit_column1"]/
                          width/text())[1] 
      with 61 ')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM