?
Solved

select xmltype column record/xml fragments and store it in associative array in plsql

Posted on 2008-10-30
4
Medium Priority
?
1,083 Views
Last Modified: 2013-12-07
hi experts,

i'm trying to select an xml elements/attributes value from xmltype column and store it in associative array for further looping requirement. what i don't really get it is in pl/sql, value extracted using xpath from xml document is in a list of xml fragments(element/ attribute values). what type should i declare to hold this information?

please advise and thanks,
wxII
0
Comment
Question by:wxII
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 74

Expert Comment

by:sdstuber
ID: 22847366
what version of Oracle?  It helps to us to give answers, and also for you to get the attention of more people if you include the zones for the version you are interested in.
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 750 total points
ID: 22847380
for this particular question though, the answer will likely be version independent.  The return type will be xmltype.  Unless you explicitly extract the text of a node or the values within a node or attribute.  Then they will be varchar2.

What are you trying to do?  Are you sure you want to pull the data out into a collection?  Why not just iterate through the xml docment itself or open a cursor.
0
 
LVL 27

Assisted Solution

by:sujith80
sujith80 earned 750 total points
ID: 22847543
Generally VARCHAR2 should do. If the size of the extracted fragment is greater than 32k you may use CLOB.

THe return value of the extracted value depends on which function you are using EXTRACT/ EXTRACT VALUE.

Read the oracle documentation on this.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions051.htm
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions052.htm
0
 

Author Comment

by:wxII
ID: 22848520
the version i'm using is oracle 11g 11.1.0.6.

 the reason i'm storing it in associative array is because i 'm gonna use it for referencing with other relational table. the xml column only contains the hierarchical format. since storing hierarchical format using conventional relational table is very tedious, so i decided to use xml where the nature of it is hierarchical.

another supporting reason for this is because i want to limit the query on data as much as possible by query once for all the hierarchical data that i need and just process it with iteration and conditional situation.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Suggested Courses

752 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