10g XMLTABLE - can I return col XMLTYPE as well as retrieve specific columns

Hello

(This is for version 10.2.0.4)

Currently, we have a giant XML column that contains many pieces to it. Divide us those in different parties through XMLSEQUENCE and then go to extract information from the other two XMLTYLE columns. I wish I could use XMLTABLE to reach the XMLTYPE columns to each other in a SQL statement, because I think it should be more effective. (We will have problems when the large XML column has 400 or more parts in - closure and do extract the values in two columns of xmltype + 400 times turns out to be slow going!)

Anyway, I want to do is use XMLTABLE to produce a table for each column-shaped structure, then join them if this 1st part of col1 = part 1 in col2 = 1st party to col3.

I looked around the documentation and google, but I'm stuck at a particular point: I would like to return XMLTYPE as values extracted from this XMLTYPE in the XMLTABLE on each column. I can't find a way to do it.

Here is an example (that I got from http://thinktibits.blogspot.com/2011/03/oracle-xmltable-example-part-1.html) that hopefully will explain more clearly what I want to do, taking a column starting with:
CREATE TABLE xml_test
(NOTEBOOK XMLTYPE);

insert into xml_test values ('<?xml version="1.0" encoding="UTF-8"?><Product Type=''Laptop''><Notebook Brand="HP" Model="Pavilion dv6-3132TX Notebook"><Harddisk>640 GB</Harddisk><Processor>Intel Core i7</Processor><RAM>4 GB</RAM></Notebook><Notebook Brand="HP" Model="HP Pavilion dv6-3032TX Notebook"><Harddisk>640 GB</Harddisk><Processor>Intel Core i7</Processor><RAM>6 GB</RAM></Notebook><Notebook Brand="Toshiba" Model="Satellite A660/07R 3D Notebook"><Harddisk>640 GB</Harddisk><Processor>Intel Core i7</Processor><RAM>4 GB</RAM></Notebook><Notebook Brand="Toshiba" Model="Satellite A660/15J Notebook"><Harddisk>640 GB</Harddisk><Processor>Intel Core i5</Processor><RAM>6 GB</RAM></Notebook></Product>');

commit;

SELECT NOTEBOOKS1.*
  FROM xml_test PO,
       XMLTable('//Notebook' PASSING PO.NOTEBOOK) notebooks1;
       
COLUMN_VALUE                                                                                                                                           
-------------------------------------------------------------------------------------------------------------------------------------------------------
<Notebook Brand="HP" Model="Pavilion dv6-3132TX Notebook"><Harddisk>640 GB</Harddisk><Processor>Intel Core i7</Processor><RAM>4 GB</RAM></Notebook>
<Notebook Brand="HP" Model="HP Pavilion dv6-3032TX Notebook"><Harddisk>640 GB</Harddisk><Processor>Intel Core i7</Processor><RAM>6 GB</RAM></Notebook>
<Notebook Brand="Toshiba" Model="Satellite A660/07R 3D Notebook"><Harddisk>640 GB</Harddisk><Processor>Intel Core i7</Processor><RAM>4 GB</RAM></Notebook>
<Notebook Brand="Toshiba" Model="Satellite A660/15J Notebook"><Harddisk>640 GB</Harddisk><Processor>Intel Core i5</Processor><RAM>6 GB</RAM></Notebook>

4 rows selected.

SELECT NOTEBOOKS2.*
  FROM xml_test PO,
       XMLTable('//Notebook' PASSING PO.NOTEBOOK
       COLUMNS  row_num for ordinality,
                "BrandType"    CHAR(10) PATH '@Brand',
                "ProductModel" CHAR(50) PATH '@Model',
                "Harddisk" CHAR(10) PATH 'Harddisk',
                "Processor" CHAR(20) PATH 'Processor',
                "RAM" CHAR(10) PATH 'RAM') AS NOTEBOOKS2;

   ROW_NUM BrandType  ProductModel                                       Harddisk   Processor            RAM       
---------- ---------- -------------------------------------------------- ---------- -------------------- ----------
         1 HP         Pavilion dv6-3132TX Notebook                       640 GB     Intel Core i7        4 GB      
         2 HP         HP Pavilion dv6-3032TX Notebook                    640 GB     Intel Core i7        6 GB      
         3 Toshiba    Satellite A660/07R 3D Notebook                     640 GB     Intel Core i7        4 GB      
         4 Toshiba    Satellite A660/15J Notebook                        640 GB     Intel Core i5        6 GB      

4 rows selected.
What I would like is to have the first statement COLUMN_VALUE select content to appear as a column in the second selection - is this possible?

In the worst case, I could join, only it generates a Cartesian product, because I do not know how to qualify the lines from the first XMLTABLE query (if I used the rownum in the query itself, that guarantee to come out in the same order as the XMLTABLE results? Would be part 1 always labeled tier 1, part 2, row2, etc.?).

I hope this makes some kind of sense - I'm not on terms XML, unfortunately.

ETA: If there is no way to achieve through XMLTABLE, is there any other way to reach him?

Published by: Boneist on December 2, 2011 17:14

Hello

Define an additional XMLType projection in the clause of COLUMNS with PATH = '.' (the context item):

SQL> set long 500
SQL>
SQL> SELECT x1.*
  2  FROM xml_test t
  3     , XMLTable('/Product/Notebook' PASSING t.notebook
  4         COLUMNS rn FOR ORDINALITY
  5               , BrandType      VARCHAR2(10) PATH '@Brand'
  6               , ProductModel   VARCHAR2(50) PATH '@Model'
  7               , Harddisk       VARCHAR2(10) PATH 'Harddisk'
  8               , Processor      VARCHAR2(20) PATH 'Processor'
  9               , RAM            VARCHAR2(10) PATH 'RAM'
 10               , NoteBook_node  XMLType      PATH '.'
 11       ) x1
 12  ;

        RN BRANDTYPE  PRODUCTMODEL                                       HARDDISK   PROCESSOR            RAM        NOTEBOOK_NODE
---------- ---------- -------------------------------------------------- ---------- -------------------- ---------- --------------------------------------------------------------------------------
         1 HP         Pavilion dv6-3132TX Notebook                       640 GB     Intel Core i7        4 GB       
                                                                                                                      640 GB
                                                                                                                      Intel Core i7
                                                                                                                      4 GB
                                                                                                                    

         2 HP         HP Pavilion dv6-3032TX Notebook                    640 GB     Intel Core i7        6 GB       
                                                                                                                      640 GB
                                                                                                                      Intel Core i7
                                                                                                                      6 GB
                                                                                                                    

         3 Toshiba    Satellite A660/07R 3D Notebook                     640 GB     Intel Core i7        4 GB       
                                                                                                                      640 GB
                                                                                                                      Intel Core i7
                                                                                                                      4 GB
                                                                                                                    

         4 Toshiba    Satellite A660/15J Notebook                        640 GB     Intel Core i5        6 GB       
                                                                                                                      640 GB
                                                                                                                      Intel Core i5
                                                                                                                      6 GB
                                                                                                                    
 

I'm not sure that understand the rest of your condition.
You want to still break through the XMLType generated in a set of relational lines, or repeat on different columns of the same base table?

Tags: Database

Similar Questions

  • can I return an iwatch?

    can I return a Apple Watch

    Hello

    You have 14 days calendar to return an element from the date you received it.

    How to return an element > http://www.apple.com/shop/help/returns_refund

  • Can I return my iPad?

    Hello!

    My short story:

    Last year (August), I bought refurbished iPad 2 Air (#1), a couple of days later, I had to make an appointment at the Genius Bar, because in one of the corners is a screen problem (colors where dull/gray; on white canvas, I could see gray area). They gave me a brand new iPad (#2), directly from the box BUT they are brand new with plastic wrap to the box which came with a refurbished. He was allowed for a few months. During the night, something happened to the screen; He literally cracked under the glass. Like this: poof! Then I went to the Genius Bar again and they gave me another and brand new, iPad (#3). And? #3 has the same question as #1... Tomorrow I have another visit to the Genius Bar, but I'm tired of this... iPad have still warranty (like 2 weeks, counting from #1). Can I return to the contrary to get new iPad? Or at least I can get credit store or something? Someone at - it know how it works? I come from Poland, we have no stores Apple, just Premium Resellers, holds to a different font. I bought iPad here, in the United States. I'm not familiar with Apple / policies of the United States

    Benji.

    # You have only 14 days from the original purchase return, that has long since passed. Each iPad you get as a replacement will be accompanied by a guarantee of 90 days, or for the rest of the origin of the iPad, longer warranty applies. This entitles you to replacements, but not a refund.

  • I use the beta version, how can I return to the basis of Firefox?

    How can I return to the basis of Firefox instead of the beta?

    Backup of your profile and you will not lose your add-ons and bookmarks.

  • How can I return Ipad lost the Original owner

    How can I return Ipad lost to the Original owner. I found this in a restaurant and he didn't. is it possible to give that ipad

    Of course, follow this:

    Report a lost or stolen - Apple Support Apple product

    Please send back

    EDIT: of course, you can leave in the police station the nearest and the report as lost, place, time, etc. or to personnel in the site you found.

  • Can I return to my old browser if Foxfire I don't like it?

    Can I return to my old, not Foxfire browser so as not Foxfire?
    I tried different o awhile back and it uninstalled browser on the device (not this one).
    Also. Two other browser are used on the same device, but not same schedule?
    It is more difficult to use this query. Text entry screen not good fit on the screen of the device, unstable
    Phone preference of use. You txtmsg or email number, ring it so I'm going on my dime. Number, hassle this last one I do.

    Device: DroidX

    Firefox is autonomous. It does not interfere with all other browsers installed on your phone.

  • How can I return to 6.3 4.0 I have never had a problem with 3.6 and now 4.0 crashes all the time tell me how to go back

    How can I return to 4.0 3.6 I've never had a problem with 3.6 and now 4.0 crashes all the time tell me how to go back

    Downgrade to Firefox 3.6 first of all uninstall Firefox 4, but do not select the option 'remove my Firefox personal data '. If you select this option, it will delete your bookmarks, passwords and other user data.

    Then you can install the latest version of Firefox 3.6 available to http://www.mozilla.com/en-US/firefox/all-older.html - it will automatically use your favorite courses, passwords etc.

    I recommend, to avoid possible problems with decommissioning, accessing your profile folder and delete the following files if they exist - extensions.cache, extensions.rdf, extensions.ini, extensions.sqlite and localstore.rdf. Delete these files will force Firefox to rebuild the list of installed extensions, check their compatibility and cancel the toolbar customizations.

    For more information on how to find your profile folder, see https://support.mozilla.com/kb/Profiles

  • How can I return to my home page after the opening of e-mail or the face-book without going through the start menu

    Since the installation of 4.0, I have no 'home' button How to return to my homepage after opening other windows, such as mail electronics or face book without going through the start menu or Favorites? Can I return to 3.6?

    There is a home button on the corner right next to your search box in firefox.

  • 4.0 using I can go to a mut "view full screen", that I can't return to a normal view. ESC does nothing. Any ideas?

    4.0 using I can go to a mut "view full screen", that I can't return to a normal view. ESC does nothing. Any ideas?

    There are two ways to exit full screen mode. Press the F11 key on your keyboard, which must immediately exit fullscreen. The other is to move your mouse to the top of your monitor, which is expected to display navigation bar of Firefox. You can then click the button restore, which should be at the top right.

    Hope that helps.

  • New iPhone launched yesterday and I just picked up my iPhone to a lower model earlier this month.  Can I return or Exchange for a new unit which is always on a guarantee?

    New iPhone launched yesterday and I just picked up my iPhone to a lower model earlier this month.  Can I return or Exchange for a new unit which is always on a guarantee?

    If your current iPhone is still within the retailer's return policy where

    you bought it, you can return before the closure of the back window. If

    the return period is passed, then you need to sell your current

    iPhone and use the funds for the purchase of a newer model.

    All Exchange warranty would be for the same exact as iPhone being

    replaced - same color, same memory, same State locked/unlocked.

    Protection guarantee against manufacturing defects and does not

    apply when the owner wishes to change to another iPhone out of warranty issue.

  • Why my dial of the watch is amplified? I can't return to normal size without turning off power.

    Why is my dial sport 38mm enlarged? I can't return to normal size without turning off power. How prevent and repair without turning extinguished/turned on?

    Hello

    Zoom (an accessibility function) has been activated on your watch.

    • To turn off the Zoom:
      • On your iPhone, in the application of the watch, go to: My Watch (tab) > general > accessibility > Zoom - put it off.
      • Or on your watch, go to: homescreen (via a simple press on the digital Crown) > (cog icon) settings > general > accessibility > Zoom - tap and enable / disable.
    • If the accessibility shortcut has been enabled and configured for the Zoom, you can also enable and disable functionality more conveniently:
      • On your watch: quickly press the digital Crown (the round button) three times.
    • To set up accessibility shortcuts:
      • On your iPhone, in the application of the watch, go to: Watch My > general > accessibility > accessibility shortcut (bottom) > select / deselect Zoom.
  • How can I return the virtual keyboard (now in the center of the screen) down?  I don't see what I'm typing so I hope it works.  Help, please

    After a recent update the keyboard appears in the center of the screen, rather than at the end. How can I return it down?

    Press and hold the keypad icon bit, then slide your finger up to 'Dock '.

  • Just bought a new I Pad Air 2 December 4, 2015.  IBook started with a printed blue/white background.  The next day woke to white/black print and can not return blue background.

    Just bought a new I Pad Air 2 December 4, 2015.  IBook started with a printed blue/white background.  The next day woke to white/black print and can not return blue background.

    Open a book, tap, tap of he two, disable auto-nuit theme.

  • my audio syestem of beats went when I choose windows 8, how can I return it with the full version?

    my audio syestem of beats went when I choose windows 8, how can I return it with the full version? I have hp pavilion dv4 5110tx

    Hello

    Try the following.

    Download IDT Audio Installer on the link below and save it in your downloads folder.

    http://ftp.HP.com/pub/SoftPaq/sp59501-60000/sp59882.exe

    One time finished, open windows control panel, open Device Manager and open sound, video and game controllers.  Right click on the IDT device and select uninstall - also, you should get a command prompt to delete the current driver, check the box allow this and then proceed to uninstall.

    Then, download and reinstall the Chipset driver on the following link.

    Chipset Driver - Windows 8.

    After reinstalling, restart the laptop and let Windows load completely.  Open your download folder, right-click on the IDT Installer and select "Run as Administrator" to launch the installation.  When this has completed, restart the computer again before checking if the Beats Audio is now listed in the windows control panel.

    Kind regards

    DP - K

  • How can I return the path of a test step VI in LabVIEW?

    I would create a VI that will return all of the VI paths that are associated with the test steps in a TestStand sequence.  How can I return the path of the VI associated with a test step?  Here is a starting point that will return the first step of the sequence.

    You must convert the Module to a LabVIEWModule (use the variant to the data node), then you can use LabVIEWModule.VIPath.  If you use TestStand 2010, you can call LabVIEWModule.GetVIAbsolutePath to find the VI in the case you are calling with a project.

Maybe you are looking for