XMLTABLE where node names become columns

I hope someone can help me with this XMLTABLE question.
I have XML data stored in a column of a table. I want to map the contents of the XML into relational rows and columns. My request is rather simple: I would like each name of node in the XML to become a column, the contents of the column equal to the name of the node.
Here is what rows in my table look like:
ID      XML_CONTENT                            
832-Q   <LevelOne>                 
            <LevelTwo_A>
                <LevelThree_1>
                    <h1>3.4</h2>
                    <h2>5.6</h2>
                </LevelThree_1>
                <LevelThree_2>
                    <h1>1.2</h2>
                    <h2>8.2</h2>
                </LevelThree_2>
                <LevelThree_3>
                    <h1>5.2</h2>
                    <h2>5.22</h2>
                </LevelThree_3>
            </LevelTwo_A>
            <LevelTwo_A>
                <LevelThree_4>
                    <h1>3.9</h2>
                    <h2>1.9</h2>
                </LevelThree_4>
            </LevelTwo_A>
        </LevelOne>
562-B   <LevelOne>
            <LevelTwo_B>
                <LevelThree_1>
                    <h1>32.4</h2>
                    <h2>5.5</h2>
                </LevelThree_1>
                <LevelThree_4>
                    <h1>10.2</h2>
                    <h2>8.1/h2>
                </LevelThree_4>
            </LevelTwo_B>
        </LevelOne>And what I would like as output is something like this:
ID     L2           L3              H1       H2
832-Q  LevelTwo_A   LevelThree_1    3.4      5.6
832-Q  LevelTwo_A   LevelThree_2    1.2      8.2
832-Q  LevelTwo_A   LevelThree_3    5.2      5.22
832-Q  LevelTwo_A   LevelThree_4    3.9      1.9
562-B  LevelTwo_B   LevelThree_1    32.4     5.5
562-B  LevelTwo_B   LevelThree_4    10.2     8.1One way to put this is that it is really the H1 and H2 elements I'm interested in. Each node name in the path leading up to that I want to become columns in my output. Note: My H1 and H2 elements are always at exactly the depth as indicated in the example. I'm not interested in the very first node name ('LevelOne') of XML_CONTENT, simply because in my case it is always similar among the rows in my table.
I've tried numerous forms of XMLTABLE but just cannot seem to get this right. At the same time I think my request is rather simple so I'm a bit embarrassed that I cannot figure this one out. Anyone can help ?
Thanks.
Edited by: user491370 on Apr 11, 2010 9:51 PM

Hi,
Your sample had to be corrected a little (e.g. &lt;h1&gt;3.4&lt;/h2&gt;) but here goes :
-- < Data sample ----------------------------------------------------
WITH t AS (
SELECT '832-Q' id, xmltype(
'<LevelOne>                 
   <LevelTwo_A>
     <LevelThree_1><h1>3.4</h1><h2>5.6</h2></LevelThree_1>
     <LevelThree_2><h1>1.2</h1><h2>8.2</h2></LevelThree_2>
     <LevelThree_3><h1>5.2</h1><h2>5.22</h2></LevelThree_3>
   </LevelTwo_A>
   <LevelTwo_A>
     <LevelThree_4><h1>3.9</h1><h2>1.9</h2></LevelThree_4>
   </LevelTwo_A>
</LevelOne>'
) doc
FROM dual
UNION ALL
SELECT '562-B', xmltype(
'<LevelOne>
   <LevelTwo_B>
     <LevelThree_1><h1>32.4</h1><h2>5.5</h2></LevelThree_1>
     <LevelThree_4><h1>10.2</h1><h2>8.1</h2></LevelThree_4>
   </LevelTwo_B>
</LevelOne>'
FROM dual
-- ---------------------------------------------------- Data sample >
SELECT t.id, x.*
FROM t, xmltable(
'for $i in $d//*[h1|h2]
  return element row { attribute L3 { local-name($i) },
                       attribute L2 { local-name($i/..) },
                       $i/h1,
                       $i/h2 }'
  passing t.doc as "d"
  columns
   l2 varchar2(30) path '@L2',
   l3 varchar2(30) path '@L3',
   h1 varchar2(30) path 'h1',
   h2 varchar2(30) path 'h2'
) x;The key here is to select each parent of "h1" and "h2", then we can construct each "row" (function local-name() is used to retrieve the node name).

Similar Messages

  • Where are Hierarchy node names stored in BW?

    When I enter hierarchy view of an infoobjects master data, I can see a field called node name. If I want to use that as filter criteria, where do I go to find that? Where is it stored?

    Thanks! How do you see the cost element assignments to these nodes? Where is the relationship? How does BW know which cost elements fall under a specific node?

  • Concurrent Manager Node Name Issue

    Hi All,
    Recently one of EBS 11i (11.5.10.2 + RHEL 4.7) Node (VM Node) has been cloned to another node. So i had to change the Host name for the cloned application. I followed the meta link note 338003.1 and 341322.1. I am successfully changed the host name and able to access the application as well. When i check the Concurrent manager process's status, its showing Actual-1 and Target -1. B*ut the problem is some of process's node name is showing the previous node name (the name of the node from where cloned).* For example Output Post Processor's node name is showing the previous one and its status showing Actual - 0 and Target - 1. Please let me know why this has happened and also how can i solve this issue?
    Thanks,
    Mani

    Please run cmclean.sql script as per (Concurrent Processing - CMCLEAN.SQL - Non Destructive Script to Clean Concurrent Manager Tables [ID 134007.1]) and check then.
    If you still have the same issue, update FND_CONCURRENT_QUEUES table (TARGET_NODE column) -- Troubleshooting the "Error Occurred While Attempting to Establish an Applications File Server Connection" [ID 117012.1]
    Please also see (Concurrent Processing - CCM.sql Diagnostic Script to Diagnose Common Concurrent Manager Issues [ID 171855.1]).
    Thanks,
    Hussein

  • XML node name matching with regular expressions

    Hello,
    If i have an xml file that has the following:
         <parameter>
              <name>M2-WIDTH</name>
              <value column="09" date="2004-10-31T19:56:30" row="03" waferID="PUK444150-20">10.4518</value>
         </parameter>
         <parameter>
              <name>M2-GAP</name>
              <value column="29" date="2004-10-31T19:56:30" row="06" waferID="PUK444150-03">2.864</value>
         </parameter>
         <parameter>
              <name>RES-LENGTH</name>
              <value column="29" date="2004-10-31T19:56:30" row="06" waferID="PUK444150-03">2.864</value>
         </parameter>
    Is there anyway i can get a list of nodes that match a certain pattern say where name=M2* ?
    I cant seem to find any information where i can match a regular expression. I see how you can do:
    String expression=/parameter[@name='M2-LENG']/value/text()";
    NodeList nodes = (NodeList) xPath.evaluate(expression, inputSource, XPathConstants.NODESET);
    But i want to be able to say:
    String expression=/parameter[@name='M2-*']/value/text()";
    Is this possible? if so how can i do this?
    Thanks!

    As implemented in Java, XPath does not support regular expressions, but in most cases there are workarounds thanks to XPath functions. Correct me if I'm wrong, but setting your expression against the XML document (i.e. because there are no "name" attributes in the whole document) I think you mean to get the value of the <value> elements that have a <parameter> parent element and a <name> sibling element whose value starts with "M2-". If that is the case, you can use the following query expression:String expression = "//parameter/value[substring(../name,1,3)='M2-']";Sorry if I misunderstood the meaning of your expression, but I hope this will help you get the hang of using XPath functions as a substitute for regular expressions.

  • In the top, calendar sheet, there are job names in column B. In the sheets below are individual job, tracking sheets. I need a formula to link the sheets by job name so I don't have to go back and edit as I go.

    file://localhost/Users/georgegalli/OFFICE/Time%20sheets/September%202013%20copy. numbers
    I hope I'm asking this the right way......
    Sheet "31 Day diary" is linked to sheet "Caramainco". So, no matter what job we are on, the days are always recorded to the Caramanico sheet.
    Is there a formula that will recognize the job name in column B sheet 1 and link to a sheet below of the same name?

    This is a part of the linked sheet from one job.....( Caramanico ) notice where i had to delete days where we weren't there.
    Date
    George
    Aaron
    Mike
    Wed, Aug 28, 2013
    0.00
    0.00
    0.00
    Thu, Aug 29, 2013
    0.50
    1.00
    0.00
    Fri, Aug 30, 2013
    0.50
    1.00
    0.00
    Sat, Aug 31, 2013
    0.00
    0.00
    0.00
    Sun, Sep 1, 2013
    0.00
    0.00
    0.00
    Mon, Sep 2, 2013
    0.00
    0.50
    0.50
    Tue, Sep 3, 2013
    0.00
    0
    0
    Wed, Sep 4, 2013
    0.00
    0
    0
    Thu, Sep 5, 2013
    0.00
    0.00
    0.00
    Fri, Sep 6, 2013
    0.00
    0.50
    0.00
    Sat, Sep 7, 2013
    0.00
    0.50
    0.00
    Sun, Sep 8, 2013
    0.00
    0.00
    0.00
    Mon, Sep 9, 2013
    0.50
    1.00
    0.00
    Tue, Sep 10, 2013
    0.00
    0.00
    0.00
    Wed, Sep 11, 2013
    0.00
    1.00
    0.00
    Thu, Sep 12, 2013
    1.00
    1.00
    1.00
    Fri, Sep 13, 2013
    1.00
    1.00
    1.00
    Sat, Sep 14, 2013
    0.50
    0.00
    0.00
    Sun, Sep 15, 2013
    0.00
    0.00
    0.00
    Mon, Sep 16, 2013
    0.50
    1.00
    1.00
    Tue, Sep 17, 2013
    0.00
    0.00
    0.00
    Wed, Sep 18, 2013
    0.00
    0.00
    0.00
    Thu, Sep 19, 2013
    0.50
    0.00
    0.00
    Fri, Sep 20, 2013
    0
    0
    0
    Sat, Sep 21, 2013
    0
    0
    0
    Sun, Sep 22, 2013
    0
    0
    0
    Mon, Sep 23, 2013
    0
    0
    0
    Tue, Sep 24, 2013
    1.50
    1.50
    1.50
    Wed, Sep 25, 2013
    0.00
    0.00
    0.00
    Thu, Sep 26, 2013
    1.00
    1.00
    1.00
    Fri, Sep 27, 2013
    1.00
    1.00
    1.00
    Sat, Sep 28, 2013
    1.00
    0.00
    0.00
    Sun, Sep 29, 2013
    0.50
    0.00
    0.00
    Mon, Sep 30, 2013
    1.50
    0.00
    1.50
    Tue, Oct 1, 2013
    1.00
    1.00
    1.00
    Wed, Oct 2, 2013
    0.50
    0.50
    0.00
    Thu, Oct 3, 2013
    1.00
    1.00
    1.00
    Fri, Oct 4, 2013
    Sat, Oct 5, 2013
    0.00
    0.00
    0.00
    Sun, Oct 6, 2013
    0.00
    0.00
    0.00
    Mon, Oct 7, 2013
    0.00
    0.5
    0.00
    Tue, Oct 8, 2013
    0.00
    0.00
    0.00
    Wed, Oct 9, 2013
    0.00
    0.00
    0.00
    Thu, Oct 10, 2013
    0.00
    0.00
    0.00
    Fri, Oct 11, 2013
    0.00
    0.00
    0.00
    Sat, Oct 12, 2013
    0.00
    0.00
    0.00
    Sun, Oct 13, 2013
    0.00

  • JTree node name

    hi,
    i have a jtree with a specific renderer, this renderer returns a jlabel to represent each node in the tree. The text can be either bold or normal, based on custom properties of the node being rendered. Sometimes, during the execution of the program, these properties change and the jtree is refreshed, it all works fine and the nodes changed become bold as i want, the only problem is that if the text changes size, the full name does not appear. For example when i have a node with this name :
    Inbox
    When the property changes, and the nome becomes bold, the name changes to :
    Inb...
    I have tried everything i can but i just can't solve the problem. anyone knows?
    best regards
    Zede

    If you are using a DefaultTreeModel as your model, then when you change the text or the formatting of the node, call the model's nodeChanged(TreeNode) method.

  • How to compare index names and columns from different user?

    I am using below query to compare two indexes from 2 different users but even though index name and columns are same... result shows me they are different.. what I am doing wrong? Thanks
    WITH t AS
            (SELECT COUNT (DISTINCT index_owner || index_name || indexed_cols)
                       cnt
               FROM (  SELECT index_owner,
                              index_name,
                              listagg (column_name, ',')
                                 WITHIN GROUP (ORDER BY column_position)
                                 indexed_cols
                         FROM dba_ind_columns
                        WHERE index_name='XPKTBL_A'
                     GROUP BY index_owner, index_name))
    SELECT CASE
              WHEN cnt > 1 THEN 'Indexes are different'
              WHEN cnt = 0 THEN 'Indexes dont exist'
              WHEN cnt > 1 THEN 'Indexes are identical'
           END
              commnt
      FROM t
    Result:
    Indexes are different
    but Actually if you check below they are same After when I run this query:
    SELECT index_owner,
             index_name,
             listagg (column_name, ',') WITHIN GROUP (ORDER BY column_position)
                indexed_cols
        FROM dba_ind_columns
       WHERE index_name='XPKTBL_A'
    GROUP BY index_owner, index_name;
    Result:
    Index_owner
    Index_name
    Index_cols
    USER1
    XPKTBL_A
    FIELD_A1
    USER2
    XPKTBL_A
    FIELD_A1

    Hi,
    Erhan_toronto wrote:
    I am using below query to compare two indexes from 2 different users but even though index name and columns are same... result shows me they are different.. what I am doing wrong? Thanks
    WITH t AS
            (SELECT COUNT (DISTINCT index_owner || index_name || indexed_cols)
    So index_owner is 'USER1' in one case, and 'USER2' in the other; right?
    A string that starts with 'USER1' will be distinct from a string that starts with 'USER2', no matter what the rest of the string contains.  Maybe you don't want to compare the owners, or maybe you meant to use some other column (such as table_name) instead of index_owner).
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE, CREATE INDEX and CONNECT statements), and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • Query to find out the table name and column name..

    Hi Experts,
    I have an Oracle DB in which has more than 50 tables and 100,000 records. I want to get the record which contains *"ITxtVarValue references a non existing text"* the text.
    Is there any query there to find out the table name and column name of this particular record where it reside?
    Please help. Any help will be rewarded.
    Thanks,
    G

    Using this forum's search function, I found a thread that should give you an idea: How to find out a tablename
    C.

  • Names of column appearing in alv output after changing layout in alvgrid?

    Hi all
    I have a requirement where I am displaying 20 fields using alv grid(cl_gui_alv_grid). Now each time when I run I can change layout and can display any number of columns in output using change layout option.
    My requirement is i need to know the column names of the fields which are displayed upon changing layout in output. Using this column names I have to write some logic in code. Each time number of column may vary as per the user selection. Is there any method or way to get the names of columns selected in output display?
    Please help me in this regard.

    Hi,
    During run time you will get the ALV layout info using this function module.
    REUSE_ALV_GRID_LAYOUT_INFO_GET
    Regards,
    Anversha

  • E4X : How to get elements that contain a string pattern in the node name?

    Is there a way to extract children from an XMLList where the node name of a child contains a string pattern?
    For example :
    <record>
         <XblahX/>
         <cow/>
         <YblahY/>
    </record>
    How to get the elements of record that have a node name that contains the string "blah"?

    var rec:XML = <record>
         <XblahX/>
         <cow/>
         <YblahY/>
    </record>;
    var r:RegExp = /blah/;
    var elems:XMLList = rec.children().(localName().search(r)>-1);
    trace(elems.toXMLString())

  • Wrong node name passing to HPM via SCOM to HPOM SCinterop connector

    Hello,
    We are experience an intermittant issue with our SCOM to HPOM SCInterOP connector. We are having an issue where the SCOM RMS server  name  is being passed to HPOM as the node name for alerts when in SCOM the node name is a completely diferent
    server.
    An example would be an IIS appplication pool error that is generated. The path for the alert will specificy a SCOM Agent node, such as "server1.acme.com", however when the event is generated in HPOM the node name will come up with our SCOM RMS server
    name eg: "scomsrv1.acme.com".
    We have an automated ticketing system which then generates a ticket in our service desk application however when this situation occurs it is very difficult for a non SCOM people to acurately determine what server is actually generating the error.
    We are are running SCOM 2007 R2 CU6 and our HP OM server is 8.10 with the latest patches applied.
    Any asistance would be much appreciated.
    Regards
    Tony

    Tony,
    There are 2 issues that can cause this.
    1 - The node name of the IIS server 'server1.acme.com' fails DNS lookup and the connector reverts to the the RMS server name to guarantee the alert is delivered to HPOM.
    2 - The connector uses the PrincipleName of the alert generated from SCOM. If the name does not resolve in DNS the connector will revert to the RMS server and use that to guarantee delivery to HPOM. There are a few MPs out there that do not set the PrincipleName
    correctly in the alert which causes this issue and it is really an MP issues and not a connector issues.
    There's an internal doc that addresses this and provides a workaround. If you'd like a copy you can send and email to [email protected] and replace the something with xplatext.
    Regards,
    -Steve

  • Dashes in xml node names

    I need to parse an xml document returned by a web-service. It does not, nor do we want it to, follow any SOAP or wdsl standard.. However I still need to parse it (hence the flex becomes unflexible).
    Some of the nodes names in the xml document have dashes it is.. (ex. <node-name></node-name>) However flex does not let me access these nodes..
    If I try and parse a mx.rpc.events.ResultEvent thus :
    someObject = event.result.root.node-name as someObjectType;
    I get an error: 1120: Access of undefined property structure.  ...  line 16    1253139374175    81
    However when I traverse the event object in the debugger.. the result.root.node-name object is in debugger as an ObjectProxy.. so what gives? I have to use boring one word node names? Is Flex so inFlexible?

    Hey! thanks for the advice! I did try this, but I don't think I was using the object correctly. I wast to try and bind the text value of an xml node to a control Object..
    Back to the books, then
    Thanks again,

  • Character Restriction in Node Name

    Hi,
    Anyone can advise where the character restriction is set for a node name (member name).
    I want to add a member into a hierarchy, but I does not allow me to enter the following characters:
    (space), + ( ) & %. Everytime I type the character, it just like the keyboard has been locked. No message or
    error saying the character is not allowed because of a specific validation.
    Thanks.

    Hi Tanuja,
    Thanks for your help. That is correct.
    Is there a way to set the restriction into a specific hierarchy, not in system preference?
    For example, if the account name is used in HFM, then do not allow + - character in any of the name.
    While if the account name is used in Essbase only, allow the use of + - character?
    Regards,
    Lian

  • Alias Names for Column names in the Prompt

    Hi,
    I have a scenario where I am taking column names into prompt. I have used the following SQL in the SQL results under "Show" option of the Prompt.
    SELECT CASE WHEN 1=0 THEN AGE.AGE ELSE '"Orders"."By OrderDate"' END FROM " Real Time"
    UNION ALL
    SELECT CASE WHEN 1=0 THEN AGE.AGE ELSE '"Orders"."By ShipDate"' END FROM "Real Time"
    My problem here is I am getting the column names into the Prompt as "Orders"."By OrderDate" and "Orders"."By ShipDate", which is not acceptable and readable format for the user. I tried using the alias name in the SQL query this way.
    SELECT (CASE WHEN 1=0 THEN AGE.AGE ELSE '"Orders"."By OrderDate"' END) AS "By OrderDate" FROM " Real Time"
    UNION ALL
    SELECT (CASE WHEN 1=0 THEN AGE.AGE ELSE '"Orders"."By ShipDate"' END) AS "By ShipDate" FROM "Real Time"
    but it is throwing an error.Is there any way that I can assign an alias name for the column names such as OrderDate and ShipDate in the above SQL.
    Your quick respose is appreciated.
    Thanks,
    Rama

    Change ur
    SELECT CASE WHEN 1=0 THEN AGE.AGE ELSE '"Orders"."By OrderDate"' END FROM " Real Time"
    UNION ALL
    SELECT CASE WHEN 1=0 THEN AGE.AGE ELSE '"Orders"."By ShipDate"' END FROM "Real Time"
    To
    SELECT CASE WHEN 1=0 THEN AGE.AGE ELSE By OrderDate END FROM " Real Time"
    UNION ALL
    SELECT CASE WHEN 1=0 THEN AGE.AGE ELSE By ShipDate END FROM "Real Time"
    So that it displays the Name as required
    Then in the Fx for that column in the Report Use '"Orders"."@Presentation variable"'.
    This worked for me Let me know if it worked for you.

  • Need a Query that Returns both Column Name with Column Data

    Hi,
    Hope someone can assist quite quickly. I'm after a query that will return me both column name together with column data, i.e
    Table: APP_INFO
    COL1  - currently has the value of 10
    COL2  - currently has the value of 'HELLO'
    COL3  - currently has the value of 'QWERTY'
    COL4  - currently has the value of 2000Query I'm after is to return the following result set: [actual column name, actual column data]
    COL1,10
    COL2,'HELLO',
    COL3,'QWERTY'
    COL4,2000
    Any help would be much appreciated.
    Thanks.
    Tony.

    Like this ?
    SQL> select empno, ename, deptno from emp where deptno = 10;
         EMPNO ENAME          DEPTNO
          7782 CLARK              10
          7839 KING               10
          7934 MILLER             10
    SQL> select decode(t.id,1,'EMPNO',2,'ENAME',3,'DEPTNO') COLNAME,
      2  decode(t.id,1,to_char(empno),2,ename,3,deptno)
      3  from (select emp.*, rownum rn from emp
      4  where deptno = 10) emp, (select rownum id from dict where rownum <=3) t
      5  order by emp.rn, t.id
      6  /
    COLNAM DECODE(T.ID,1,TO_CHAR(EMPNO),2,ENAME,3,D
    EMPNO  7782
    ENAME  CLARK
    DEPTNO 10
    EMPNO  7839
    ENAME  KING
    DEPTNO 10
    EMPNO  7934
    ENAME  MILLER
    DEPTNO 10
    9 rows selected.Rgds.

Maybe you are looking for

  • 11g problem with Win7 starter

    Taking a class and the book came with Oracle 11g DVD. Tried to load it onto my laptop and get an error when checking the operating system. The error is something like "expecting 5.0, 5.1, or 6.0 received 6.1" which I am assuming refers to Win7 vs vis

  • Error -2147213312 with installation MediaSour

    Hi, there... I made a fresh install of my MS$ Win XP SP3. That means I had to install my soundcard drivers again, too. I own a SoundBlaster Li've!24-Bit. After I installed everything from the original CD, I started AutoUpdate. The screen told me to n

  • Updating AIR application

    I hope I am asking this question in the right forum I am working with a dev team that's writing AIR application To keep it simple, let's say this AIR application has 10 swf and 2 swc (plus other assets) All of these files are packaged inside an AIR i

  • My view is just "loading"

    I want to call my view page2 from my view main.htm, but my page is just "loading", and nothing else happens My controller "ZCL_MOBILE_DEMO_CONTROLLER1" has the method DO_REQUEST, in where I have following code:   dispatch_input( ).   request->get_for

  • Droid DNA Problems after Update

    After updating this phone to the newest Android OS (4.2.2) I have the following problems: If in the middle of a call I connect to my cars bluetooth, all sound is lost. It looks like the call is dropped but the phone does not hang up The camera often