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!

XQuery Oracle replace value

user4423142Dec 3 2013 — edited Dec 3 2013

Hi Everybody

Oracle used :  Release 11.2.0.3.0

After some days I gave up but I'm sure you have a solution.

I want to modify some elements, always the same element (same name), with using a string  and the function tokenize. I use a  for, but my problem is to know the index of the element to modify in the loop. I tried to use the function $position(), but without success. Maybe we can use an index but how, because in XQuery the variables are immuable.

Here an example :

update ingredients set sections=XMLQuery('copy $gr:=.modify(

let $values:="1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0"

for $i in $gr/ingredients/section/sub_section/ingredient/value_gr

return replace value of node $i with ora:tokenize($values,",")[5])

return $snf' passing sections returning content) where ingredient_id=601;

This request works, but obviously I want to change [5] by 1,2,3...

I think you see what I want.

Thanks in advance

This post has been answered by user4423142 on Dec 3 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 31 2013
Added on Dec 3 2013
4 comments
2,421 views