Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Update Attributes based on the text value of node using xmlexists

user8195117Jun 30 2020 — edited Jul 2 2020

Hi,

Below is the XML and there are repeating nested nodes like PD1 below. I have to modify the attributes in the repeating nodes when a text value matches some string. for example update PD1_UPC_CASE (@Error_Flag = Y and @Error_Msg) when xpath (/ROWSET/ROW/XML_DATA/PH1/PD1/PD1_UPC_CASE/text() = "000000000000"). Extractvalue does not work for repeated nodes and below XML update is not working.

The below update is updating all attributes for the node PD1_UPC_CASE which is incorrect. Could some one help me in identifying the correct node and update accordingy

update xml_doc

                               set xml_data =

                                   xmlquery(

                                   'copy $d := $x modify ( for $i in $d/ROWSET/ROW/XML_DATA/PH1/PD1[PD1_COUNT="202"][PD1_UPC_CASE = "000000000000"]

                                       return ( replace value of node $i/@Error_Flag with "Y"

                                       )    

                                     )    

                                     return $d'

                                    passing xml_data as  x

                                    returning content

                                  )

                              where xmlexists('/ROWSET/ROW/XML_DATA/PH1/PD1[PD1_COUNT="202"][PD1_UPC_CASE = "000000000000"]' passing xml_data)

  and file_id = 11973809 AND seq_num = 53650;

This post has been answered by odie_63 on Jul 1 2020
Jump to Answer
Comments
Post Details
Added on Jun 30 2020
8 comments
841 views