Solved

insert/update xmltype attribute or element in plsql stored procedure

Posted on 2008-10-29
11
1,612 Views
Last Modified: 2013-12-07
hi all,

1. how do i insert an element with attribute tag in xmltype column.

for eg. i have this document in some table with xmltype column.  

<people>
     <person name="johnny" age="10">
         <person name="mandy" age="11">
              "<i want to update/insert new elements here>"
         </person>
     </person>
</people>

and

2. update the document only on attributes, let's say i identified that i want to update person "johnny" age to 15, how am i gonna do that in PL/SQL?

please advise,
wesley
0
Comment
Question by:wxII
  • 7
  • 4
11 Comments
 
LVL 73

Expert Comment

by:sdstuber
ID: 22832585
1.

from your example it looks like you want to nest each person's node,  so your new node will be a child of mandy,
if so,  use this...

update yourtable
set yourxml = insertchildxml(yourxml,'//person[@name="mandy"]','person',xmltype('<person name="wxII" age="99"></person>'))


2.
update yourtable set yourxml = updatexml(yourxml,'//person[@name="johnny"]/@age',15)
0
 

Author Comment

by:wxII
ID: 22834238
hi, thanks for the reply, the solution 1 works great but solution 2 throws this error.


ORA-00600: internal error code, arguments: [qmcxeUpdateXml:2.1], [], [], [],[], [], [], []

any other alternatives? please advise and thanks

wxII
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 22839678
See metalink doc NOTE:745282.1

there is a patch for it
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:wxII
ID: 22840071
hi sdstuber,

i couldn't find the metalink you provided in oracle site.



0
 
LVL 73

Expert Comment

by:sdstuber
ID: 22840365
How did you search?

Do a Doc ID/ Article ID search for 745282.1.

0
 
LVL 73

Expert Comment

by:sdstuber
ID: 22840373
Or you can go directly to the patch...

Patch# 7478006
0
 

Author Comment

by:wxII
ID: 22842069
hi sdstuber,

the oracle version i'm using is 11.1.0.6, is it patched in 11.1.0.7? or only available from oracle metalink?

thanks,
wxII
0
 
LVL 73

Accepted Solution

by:
sdstuber earned 500 total points
ID: 22842275
yes you must download the patch from metalink

11.1.0.7  still has the problem, and has the same patch to correct it.

If you don't want to install the patch, you'll have to wait until 11.1.0.8 comes out
but that also will only be available via metalink.
0
 

Author Closing Comment

by:wxII
ID: 31511191
thanks for the feedback and thorough solutions.
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 22842794
glad I could help
0
 
LVL 73

Expert Comment

by:sdstuber
ID: 22842804
Do you need additional help on your other open question?
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sort a spool into file output in oracle 1 30
Oracle - SQL Where clause causing Invalid Number Error 4 35
constraint check 2 43
run sql script from putty 4 36
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many‚Ķ
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
Via a live example, show how to take different types of Oracle backups using RMAN.

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question