Skip to Main Content

DevOps, CI/CD and Automation

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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Getting XMLRecord value by position

3679117Mar 26 2018 — edited Apr 15 2018

Hello. I've got the following XML Record:

<row id="123456">

   <c1>USD</c1>

   <c2>AMOUNTS</c2>

   <c2 m="2">AMOUNT1</c2>

   <c2 m="3">AMOUNT2</c2>

   <c2 m="4">AMOUNT3</c2>

   <c2 m="5">AMOUNT4</c2>

   <c3 m="6" />

   <c4 m="7" />

   <c5>50000000</c5>

   <c5 m="2">2000000</c5>

   <c5 m="3">15000000</c5>

   <c5 m="4">2000000</c5>

   <c5 m="5">538773.07</c5>

    ....

    ....

</row>

I would like to know how is it possible for me to join the AMOUNTX to the respective value?

For e.g, AMOUNT1 should match to 2000000, AMOUNT2 should match to 15000000

I need to "play" with the value of m to actually do the mapping since not all XML Records have a fixed position for each AMOUNT.

Can anyone please help with doing such mapping?

This post has been answered by Paulzip on Mar 30 2018
Jump to Answer

Comments

cormaco
Answer

Here is one way:

with input_string(ins) as (
    select 'Chesterton, Mark;#789;#Erbach, Magnus;#786' from dual union all
    select 'Phillips, Edward;#744;#Bubba, Matthew;#782;#Mahony, Chloe;#779' from dual union all
    select 'Corbett, Paul;#784;#Johnson, Ben;#392;#Smith, Adam;#775' from dual
)
select regexp_substr(ins,',\ *([^;]+)',1,1,null,1) regex from input_string

REGEX               
--------------------
Mark                
Edward              
Paul
                
Marked as Answer by User_AS6XD · Oct 14 2021
1 - 1
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 13 2018
Added on Mar 26 2018
10 comments
1,152 views