Rebuild the parent/child (connect by prior and where clause)

Hi guys, you have a quick question for you - code as follows:


with t1 as)

Select 1 id, 'Name1' some_name, null, 'Y' parent_id of double some_flag

Union select 2 id, 'Name2', 1 parent_id, 'Y' some_flag of the double

Union select 3 id, "Name3", 2 parent_id, "n" of the double some_flag

Union select id 4, 'Name4.1', 3 parent_id, 'Y' some_flag of the double

Union select id 5, 'Name4.2', 3 parent_id, 'Y' some_flag of the double

Union select id 6, 'Name4.3', 3 parent_id, 'Y' some_flag of the double

Union select id 7, "Name5", 6 parent_id, 'Y' some_flag of the double

)

SELECT id, the_name, parent_id, null new_parent_id

de)

SELECT id, lpad (' ', (level 1) * 3) | some_name the_name, parent_id

from t1

where some_flag = 'Y '.

Start with id = 1

connect by parent_id = prior id

brothers and sisters of order by some_name

)

Output:

ID, THE_NAME, PARENT_ID, NEW_PARENT_ID

1, Name1,

2, name2, 1,.

4, Name4.1,3,

5, Name4.2,3.

6, Name4.3, 3,.

7, name5, 6,.

As you can see, id = 3 is not displayed (because of where some_flag = 'Y'), but parent_id for id in (4,5,6) shows 3.

-Only by using SQL - display 'current parent in valid results' as new_parent_id?

In this example that would be showing new_parent_id = 2 for the id in (4,5,6)

Currently on Oracle 11 g 1 material.

Similar theme (manipulate path), but seems to work with the brothers and SŒURS of ORDER BY.

SELECT id, the_name, parent_id, some_flag, new_parent_id

FROM (SELECT id, lpad (' ', (LEVEL - 1) * 3): some_name the_name,)

some_flag, parent_id,

REGEXP_SUBSTR)

REGEXP_SUBSTR)

SYS_CONNECT_BY_PATH)

DECODE (some_flag, 'Y', id), ' / ').

'[0-9]+[/]+[0-9]+$'),

(0-9] +') new_parent_id

FROM t1

WHERE some_flag = 'Y '.

START WITH id = 1

CONNECT BY PRIOR ID = parent_id

ORDER OF brothers and SŒURS some_name);

Tags: Database

Similar Questions

  • Simulate the 1 - N N - N relationship using the Parent-child structure

    Hello

    I have a 1-N relation between SKILL tables and the USER, which means 1 skill can be applied to multiple users. A jurisdiction may have a parent jurisdiction, which means that a ParentSkill inherits all the privileges of his child.

    I would like to simulate a N - N relation between the users and the skills by building a vision that goes through the parent-child relationship. This is possible for the construction?


    Current structure:
    |USERID | USERNAME | SKILLID  |
    +-------+----------+----------+
    |   1   |  Jack    |      1   |
    |   2   |  Simon   |      1   |
    |   3   |  Fred    |      3   |
    +-------+----------+----------+
    
    
    |SKILLID | DESCRIPTION   | PARENTSKILL  |
    +--------+---------------+--------------+
    |   1    |  Mechanic     |      2       |
    |   2    |  Inspector    |      3       |
    |   3    |  Supervisor   |      null    |
    +--------+---------------+--------------+
    Favorite exit (the skillid order is not important):
    |USERID | USERNAME | SKILLID  |
    +-------+----------+----------+
    |   1   |  Jack    |      1   |
    |   2   |  Simon   |      1   |
    |   3   |  Fred    |      3   |
    |   3   |  Fred    |      2   |
    |   3   |  Fred    |      1   |
    +-------+----------+----------+

    I hope that answers your needs:

    WITH
    users as
    (
        SELECT 1 as USERID, 'Jack' as USERNAME, 1 as SKILLID FROM DUAL UNION ALL
        SELECT 2 as USERID, 'Simon' as USERNAME, 1 as SKILLID FROM DUAL UNION ALL
        SELECT 3 as USERID, 'Fred' as USERNAME, 3 as SKILLID FROM DUAL
    ),
    skills as
    (
        SELECT SKILLID,CONNECT_BY_ROOT SKILLID AS ANCESTORS
        FROM
            (
                SELECT 1 as SKILLID, 'Mechanic' as DESCRIPTION, 2 as PARENTSKILL FROM DUAL UNION ALL
                SELECT 2, 'Inspector', 3 FROM DUAL UNION ALL
                SELECT 3, 'Supervisor', NULL FROM DUAL
            )
        CONNECT BY PRIOR PARENTSKILL = SKILLID
    )
    SELECT USERID,USERNAME,ANCESTORS
    FROM skills, users
    WHERE users.skillid = skills.skillid
    /
    
        USERID USERN  ANCESTORS
    ---------- ----- ----------
             1 Jack           1
             2 Simon          1
             3 Fred           3
             3 Fred           2
             3 Fred           1
    

    I hope this helps!

  • Default filters that users can delete (in the parent/child Setup)?

    Is it possible in Latitude 2.2.2 to have filters (filters of the range, refinement filters etc.) applied by default (which means that users see these filters when they log-in), but they can also remove (using bread crumbs portlet) if they wanted to? We tried to use the source of data (JSON) filters (using 'baseFunctions' setting) where we have a parent/child Setup, but it seems these filters cannot be removed once applied. Note that filters can be removed if we do not have a parent/child relationship between the data sources, but as soon as we introduce a parent/child relationship between the data sources (which we need), the GET of sticky filters and cannot be deleted. Any reason why the parent/child relationship causes the filters becoming sticky? Any way (alternate) to reach what we want?

    I think that it is a known problem (LSTUDIO-5088) and there could be a fix for this. You can contact technical support to obtain the fix.

    Dave

  • Connect by prior and leaves...

    Hi gurus...
    I have real difficulty understanding connect by prior and leaves...
    Is there a good example that you can suggest?

    Hello

    Tina wrote:
    Hi gurus...
    I have real difficulty understanding connect by prior and leaves...

    What is "connect per sheet? Post an example.
    Did you mean SHEETISCONNECT_BY_? It is a pseudo-column, documented in the manual of the SQL language:
    http://download.Oracle.com/docs/CD/B28359_01/server.111/b28286/pseudocolumns001.htm#sthref796

    Is there a good example that you can suggest?

    Make your choice:

    http://www.adp-GmbH.ch/ora/SQL/connect_by.html
    http://www.oradev.com/connect_by.jsp
    http://www.oraclepassport.com/connect%20BY%20PRIOR.html

  • Is it possible to use the Remote app with the Apple TV connected via ethernet and iPhone via WiFi?

    Is it possible to use the Remote app with the Apple TV connected via ethernet and iPhone via WiFi? When I try this Apple TV does not appear in the list of devices on my iPhone.

    Yes, I'm doing exactly this with the same put in place.

    If the problem persists the next relative to the following articles might help you.

    Troubleshooting home sharing

  • What is the latest version of Adobe Reader and where can I get it please?

    What is the latest version of Adobe Reader and where can I get it please?

    Current version is 11.0.07.

    Adobe - Adobe Reader download - all versions

  • Join the two trees connect by prior Start With and return only common records?

    Oracle 10g Release 2 (10.2)

    I have two tables which have structured data. The results, when running queries individually are correct, but I need to join tree a tree two to get only the common records between them.

    -Trees a
    SELECT ip_entity_name, entity_code, hier_level, entity_parent
    Of ip_hierarchy
    WHERE hier_level > = 3
    CONNECT BY PRIOR Entity_code = entity_parent
    START WITH entity_code = "MEWWD";

    -The two tree
    SELECT ip_entity_name, entity_code, hier_level, entity_parent
    Of ipt_hierarchy
    WHERE hier_level > = 3
    CONNECT BY PRIOR Entity_code = entity_parent
    START WITH entity_code = "IPNAM";


    If I understand correctly, the joints can not work with CONNECT BY / START WITH queries?

    A WITH clause is an option?

    If possible, I don't want to put a selection in a database to display object and join against other queries.

    Thank you.

    Hello

    jtp51 wrote:
    Oracle 10g Release 2 (10.2)
    ...
    If I understand correctly, the joints can not work with CONNECT BY / START WITH queries?

    Before Oracle 9 it was true. Since you're using Oracle 10, you can if you wish; but I'm guessing that you don't want in this case.

    A WITH clause is an option?

    If possible, I don't want to put a selection in a database to display object and join against other queries.

    Yes, a WITH clause that is an option. Viewed online, as Zhxiang has shown, are another option. Either way gives you a regular display effect without creating a database object.

    You did not show a sample and the results, so no one can tell if a join is really what you want. Other possibilities include INTERSECT or an IN subquery.

  • Get the parent-child hierarchy of column delimited

    I've been on this forum once before, and someone helped me, so I hope I can get help again!

    4-15-5987');

    Thus, the hierarchy is divided on the hyphen. first parent being 4245, then the next value is-4 (including the hyphen) and what follows is - 1, for example

    CREATE TABLE REGEXTEST
      ( ITEM VARCHAR(20)); 
    
      INSERT INTO REGEXTEST (ITEM) VALUES ('4245-4');
      INSERT INTO REGEXTEST (ITEM) VALUES ('4245-4-1');
      INSERT INTO REGEXTEST (ITEM) VALUES ('4245-4-10');
      INSERT INTO REGEXTEST (ITEM) VALUES ('4245-4-11');
      INSERT INTO REGEXTEST (ITEM) VALUES ('4245-4-12');
      INSERT INTO REGEXTEST (ITEM) VALUES ('4245-4-13');
      INSERT INTO REGEXTEST (ITEM) VALUES ('4245-4-14');
      INSERT INTO REGEXTEST (ITEM) VALUES ('4245-4-15');
      INSERT INTO REGEXTEST (ITEM) VALUES ('4245-4-15-59A7');
      INSERT INTO REGEXTEST (ITEM) VALUES ('4245-4-15-59D7');
      INSERT INTO REGEXTEST (ITEM) VALUES ('4245-4-15-59F7');
      INSERT INTO REGEXTEST (ITEM) VALUES ('4245-
    
    

    I have to be able to bind-1, -4, 4245. Perhaps the simplest is to build a new table with a primary key where it is assigned the id of the parent to the child.
    I just can't understand how to divide the individual elements and maintain the hierarchy. As previously mentioned, someone helped me with another part of the problem before where I needed to maintain the entire path of each child with the following query:

    select  nvl(prior item,item) parent,
            nvl2(prior item,item,null) child
      from  REGEXTEST
      connect by substr(item,1,instr(item,'-',-1) - 1) = prior item
      order by child,parent
    
    

    Now, if I could extrapolate that into a new table:

    CREATE TABLE FileHierarchy
    (ItemID INT NOT NULL PRIMARY KEY,
    ItemName varchar(50) NOT NULL,
    ParentID INT NULL);
    
    

    ItemName is the 4245 or - 4 or - 1 (only) - Yes, including the hyphen.

    The ID of the parent-1 would be the ID-4, etc...

    Thank you very much in advance!

    J.F. Larente

    Solution for not having stored the high level:

    SQL > select *.
    regextest 2
    3.

    POINT LEV
    -------------------- ----------
    4245 4
    4245 4-1
    4245 4-10
    4245 4-11
    4245 4-12
    4245 4-13
    4245 4-14
    4245 4-15
    4245 4-15-59 A 7
    4245 4-15-59 D 7
    4245-4-15-59F7

    11 selected lines.

    SQL > with t1 as)
    2. Select item
    regextest 3
    4 Union all the
    5 select distinct substr (item, 1, instr(item,'-',1))
    6 of regextest
    7             ),
    8 t2 as)
    9. select element,
    10 row_number() on id (order by article)
    11 from t1
    12              )
    13. select id,
    14 regexp_substr (rtrim (point,'-'), case level when 1 then ' [^-] + $' other '-[^-] + $' end) child.
    parentID 15 prior id,
    16 regexp_substr (prior rtrim (point,'-'), case level - 1 when 1 then ' [^-] + $' other '-[^-] + $' end) parent
    17 of t2
    beginning 18 with substr(item,-1) = '-'
    19 connect by substr (item, 1, instr(item,'-',-1) - 1) = prior rtrim(item,'-')
    20 and article! point prior =
    21.

    ID PARENTID PARENT CHILD
    ---------- -------------------- ---------- --------------------
    1 4245
    2 -4                            1 4245
    3 -1                            2 -4
    4 -10                           2 -4
    5 -11                           2 -4
    6 -12                           2 -4
    7 -13                           2 -4
    8 -14                           2 -4
    9 -15                           2 -4
    10-59A 7 9-15
    11 59 D 7 9 - 15

    ID PARENTID PARENT CHILD
    ---------- -------------------- ---------- --------------------
    12 59F7 9-15

    12 selected lines.

    SQL >

    SY.

  • Update the data to uppercase in the parent/child tables

    Hi gurus!

    In production, we have a table product and that is in reference by many tables making parent child relationship. By mistake, we realized last month some products have been added to lowercase and now we have a request to update all these product codes uppercase so that existing code that use these tables have no impact. Appreciate if you can give an idea about how can I update the existing data in the table parent uppercase as well as child records?

    Concerning
    Sri

    Are the product code that you need to update what is stored in the tables of children? If Yes, then you must do it in several steps, something like:

    Identify the child tables

    SELECT table_name, constraint_name
    FROM user_constraints
    WHERE r_constraint_name = (SELECT constraint_name
                               FROM user_constraints
                               WHERE table_name = 'PRODUCT_TABLE' and
                                     constraint_type = 'P');
    

    Create new product of upper-case code in the product table:

    INSERT INTO product_table
    SELECT UPPER(product_code), other_columns
    FROM product_table
    WHERE product_code <> UPPER(product_code);
    

    Update the children tables for caps product codes

    UPDATE child1
    SET product_code = UPPER(product_code)
    WHERE product_code <> UPPER(product_code);
    

    Finally, remove the tiny product_table product codes

    DELETE FROM product_table
    WHERE product_code <> UPPER(product_code);
    

    John

  • All the sites SSL Web I visit displays the message "this connection is untrusted" and shows me a false SSL certificate for a different domain name.

    When I visit a Web site that requires SSL I displays the message "this connection is untrusted". Any Web site that I visit, it's always exactly the same message and the same SSL certificate that she is no longer valid for www.thawte.com

    support.Mozilla.org uses an invalid security certificate.

    The certificate is not approved, because no sender string has been provided.
    The certificate is valid for www.thawte.com
    The certificate expired on 11/11/2011 23:59. The time now is 11:46 28/01/2012.

    When I click "Add the Exception" on a Web site and view the certificate, it is exactly the same certificate with the exact same serial number.

    I had a similar problem with Internet Explorer showing a 404 error when I visited SSL protected pages but to do a restore of the system a month ago to correct this. All other bowsers are / were very good.

    I installed Firefox 3.x month last to test something that is when the problem started. I have since uninstalled Firefox 3.x and reinstalled the latest version. I deleted all the preferences/settings, disabled modules and reinstalled many times. I did a Windows system restore to before that the problem started with no luck.

    The time / Date on my computer are correct. I have no firewall other than the windows one. I had no antivirus (netbook) until I installed a (Avast) yesterday to see if a virus was causing issues (found nothing). This problem arises on any internet connection (tested to work and home).

    Try bypassing the caveat

    or try to use the module Skip Cert error (to jump to the SSL/TLS certificate error page)

    Thank you

    Please check 'Resolved' the answer really solve the problem, to help others with a similar problem.

  • How can I remove the error "Please connect to internet and try again" when I run Acrobat DC in my laptop?

    I started DC Acrobat in my laptop, he said, "Please connect to internet and try again." I got the internet connection that I could surf the net. So I checked the internet time and it is in sync with time.windows.com.

    Should I set up to sync with time.nist.gov?

    Untitled.jpg

    Hi stephenn9960323,

    In light of this error, I suggest you to please go to the following of the KB doc link and try the troubleshooting steps:

    Log, activation, or connection errors. CS5.5 and later, Acrobat DC

    Let me know if it helps.

    Kind regards

    Ana Maria

  • Where to add the transitional attribute at the level of the entities or view level? And where to use {return getTransientAttribute()} in the entity or view?

    Mr President

    JDev 12.2.1.

    Where to add the transitional attribute at the level of the entities or view level?

    And where to use {return getTransientAttribute()} in the entity or view?

    public Number getAmount()  
      {  
        return getTransientAttribute();  
        //return (Number) getAttributeInternal(AMOUNT);  
      }  
    
    

    Concerning

    A difference I could think: place a transient attribute on EO level will make transaction dirty (DBTransaction.isDirty returns true) when the field is changed.

    From a design point of view, I tend to place the transient fields at the level VO, because most of the time they are for the presentation of the data in the user interface.

    Only when the transient fields are involved in DML operations (for example when you call a stored procedure EntityImpl.doDML) I place the transitional area on EO.

  • Can I use truncated and where clause in the statement even?

    Hello guys,.

    Can I use truncated with where clause in the same statement.


    For ex:

    TRUNCATE TABLE my_table WHERE id < 500;

    If not, that you recommend me to overtemperature to the level of high water line?


    By the way
    select * from v$version;
    Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    "CORE 11.2.0.1.0 Production."
    AMT for 64-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    >

    Thank you very much.

    Published by: 970992 on 11:14 13.Ara.2012

    >
    Okay I need an increasing amount of space. However, at the same time I want to recover the spaces empty below HWM. So, I need to use less amount of space I am inserting. Therefore, shouldn't use retractable for this?
    >
    Why waste the effort. Oracle will reuse the space below the HWM when doing inserts. You already said that you insert more lines you delete so all these will be more accustomed to the top.

    The only time where that oracle may not use space is when the space is too small to be useful. It is documented in the doc, I told you
    >
    Understanding recoverable unused space
    Over time, Update, and Delete on objects within a tablespace can create pockets of empty space that individually are not large enough to be reused for the new data.
    >
    Most uses of CONTRACTION I've seen are totally useless. If you follow the doc and run the Advisor of segment it will tell you if there is space that can be retrieved and how much. But, even once, for your use even if case will get you will Oracle while you need to reassign the new extensions, then the HWM will just go still higher.

    If pay you a heavy price in Oracle did a full table scan, update of many blocks from the table, update THE index, impact performance for other users to access the table during the SHRINK and reallocate extensions (maybe even some of the same areas) when you insert more data.

    Do not SHRINK unless you know it's necessary.

  • Update statement with joins of tables and where Clause

    Hi, I have MS SQL background and I try to execute an update statement in Oracle with joins of tables. However, the syntax below does not work but I think it works for MS SQL.

    Basically, the base table must be attached to a master table trend with monthly snapshots, an account will be only an entry for a given date monthly. Where clause must be limited to accounts within a certain range of interest rates.

    The first approach returns command SQL ORA-00933 not correctly completed, and the second approach returns ORA-01427 row below query returns multiple rows. Can anyone help? Thanks in advance!



    1:

    Update PenaltyAll
    Set a.indicator = month (b.)
    of PenaltyAll an inner join Master b on a.acctno = b.accountnumber
    where a.monthend='01/31/2009' and b.date='12/31/2008' and b.apr < 20

    2:

    Update PenaltyAll
    adjustment indicator =
    (select to_char (b., 'MM')
    of PenaltyAll an inner join Master b on a.acctno = b.accountnumber
    "where to_char (a.monthend,'mm/dd/yyyy ') = 31 January 2009"
    (et to_char(b.date,'mm/dd/yyyy') = December 31, 2008 "
    and b.apr < 20)

    Published by: sqlrookie on August 21, 2009 07:04

    I edited my post, that was my mistake, ANC you try now?

  • Insert the parent/Child records in an xml file...

    XML file pasted below:

    I loaded the xml file in a table called xml_demo that has a column of type xmltype donnees_xml.

    The Select to parent record is thus, and it works:

    INSERT INTO balit_submissions (balitdoc, documentversion, datetime_from, job_id, status, creation_datetime)
    (SELECT 'MOL'
    ((, to_number(extract(x.xml_data,'/MolDocument/DocumentVersion/@v'))
    (, to_date(substr(extract(x.xml_data,'/MolDocument/ValidTimeInterval/@v'),1,16),
    "yyyy-mm-dd HH24" T"")
    123456
    "CREATED",
    NULL VALUE
    OF xml_DEMO x WHERE
    (([existsnode(x.xml_DATA,'/MolDocument/DocumentIdentification[@v="MOL_20100331_1500_1600"]') = 1).
    /

    Having problem creating records child. From this file, I expect to create 3 folders.

    insert into balit_energy_blocks
    (
    SO_ID,
    DATETIME_FROM,
    DIRECTION,
    BLOCK_NUMBER,
    ENERGY,
    LAST_SUBMIT_DATETIME,
    PRICE_POUNDS,
    PRICE_EUROS,
    BALIT_REF,
    STATUS,
    LAST_EDIT_DATETIME,
    MOL_REASON,
    ACQUIRING_SO_AREA)
    (SELECT 'TEN'
    (, to_date(substr(extract(x.xml_data,'/MolDocument/ValidTimeInterval/@v'),1,16),
    "yyyy-mm-dd HH24" T"")
    (, DECODE(extract(x.xml_data,'/MolDocument/MolTimeSeries/Direction/@v'),'AO1','Up','Down')
    (, to_number(substr(extract(x.xml_data,'/MolDocument/MolTimeSeries/ContractIdentification/@v'),19))
    ((, to_number(extract(x.xml_data,'/MolDocument/MolTimeSeries/Period/Interval/EnergyPrice/@v'))
    sysdate
    , null - price books
    , null - price euro
    (, extract(x.xml_data,'/MolDocument/MolTimeSeries/ContractIdentification/@v')
    "PRESENTED".
    , "A96.
    NULL - acquisition of area
    sysdate
    OF xml_DEMO x WHERE
    (([existsnode(x.xml_DATA,'/MolDocument/DocumentIdentification[@v="MOL_20100331_1500_1600"]') = 1).
    /

    For example, there are 3 ContractIdentification tags. Example 1:

    < ContractIdentification v = "RTE_20100331_1500_16" / >

    I expect this selection to snatch the last issue of this string. In this case, 16.
    The selection was:
    TO_NUMBER(substr(extract(x.xml_DATA,'/MolDocument/MolTimeSeries/ContractIdentification/@v'),19))

    The result I got was:

    16RTE_20100331_1500_20NG_20100331_1500_6

    All values of contractident are concatnated and returns posted 19 go.

    Can someone help me to extract the last number of each tag value of ContractIdentification and create the 3 files

    Thank you

    James Sathiaraj

    <? XML version = "1.0" encoding = "UTF-8"? >
    < MolDocument DtdVersion = "3" DtdRelease = "0" >
    < DocumentIdentification v = "MOL_20100331_1500_1600" / >
    < DocumentVersion v = "1" / >
    < V DocumentType = "A43" / >
    < CodingScheme = v "A01" SenderIdentification = "17X100Z100Z0001H" / >
    < SenderRole v = "35" / >
    < ReceiverIdentification codingScheme = v "A01" = "10XFR-TEN - Q" / >
    < ReceiverRole v = "A04" / >
    < CreationDateTime v = "2010-03 - 31 T 14: 10:00Z" / >
    < ValidTimeInterval v = "2010-03 - 31 T 15: 00Z / 2010-03 - 31 T 16: 00Z" / >
    < codingScheme domain = "A01" v = "10YDOM-1001A001A" / >
    < MolTimeSeries >
    < ContractIdentification v = "RTE_20100331_1500_16" / >
    < ResourceProvider codingScheme = v "A01" = "10XFR-TEN - Q" / >
    < CodingScheme = v "A01" AcquiringArea = "17Y100Z100Z00013" / >
    < ConnectingArea codingScheme = v "A01" = "10YFR-TEN - C" / >
    < AuctionIdentification v = "AUCTION_20100331_1500_1600" / >
    < BusinessType v = "10" / >
    < BidTimeInterval v = "2010-03 - 31 T 15: 00Z / 2010-03 - 31 T 16: 00Z" / >
    < MeasureUnitQuantity v = "MAW" / >
    < v currency = "EUR" / >
    < MeasureUnitPrice v = "MWH" / >
    < v direction = "A02" / >
    < MinimumActivationQuantity v = "50" / >
    < v status = "A06" / >
    < period >
    < v TimeInterval = "2010-03 - 31 T 15: 00Z / 2010-03 - 31 T 16: 00Z" / >
    < resolution v = "PT60M" / >
    <>interval
    < v pos = "1" / >
    < v Qty = "50" / >
    < character v = "50.45" / >
    < / interval >
    < / period >
    < / MolTimeSeries >
    < MolTimeSeries >
    < ContractIdentification v = "RTE_20100331_1500_20" / >
    < ResourceProvider codingScheme = v "A01" = "10XFR-TEN - Q" / >
    < CodingScheme = v "A01" AcquiringArea = "17Y100Z100Z00013" / >
    < ConnectingArea codingScheme = v "A01" = "10YFR-TEN - C" / >
    < AuctionIdentification v = "AUCTION_20100331_1500_1600" / >
    < BusinessType v = "10" / >
    < BidTimeInterval v = "2010-03 - 31 T 15: 00Z / 2010-03 - 31 T 16: 00Z" / >
    < MeasureUnitQuantity v = "MAW" / >
    < v currency = "EUR" / >
    < MeasureUnitPrice v = "MWH" / >
    < v direction = "A02" / >
    < MinimumActivationQuantity v = "50" / >
    < v status = "A06" / >
    < period >
    < v TimeInterval = "2010-03 - 31 T 15: 00Z / 2010-03 - 31 T 16: 00Z" / >
    < resolution v = "PT60M" / >
    <>interval
    < v pos = "1" / >
    < v Qty = "50" / >
    < character v = "50.48" / >
    < / interval >
    < / period >
    < / MolTimeSeries >
    < MolTimeSeries >
    < ContractIdentification v = "NG_20100331_1500_6" / >
    < ResourceProvider codingScheme = v "A01" = "10X1001A1001A515" / >
    < CodingScheme = v "A01" AcquiringArea = "17Y100Z100Z00013" / >
    < CodingScheme = v "A01" ConnectingArea = "10YGB - A" / >
    < AuctionIdentification v = "AUCTION_20100331_1500_1600" / >
    < BusinessType v = "10" / >
    < BidTimeInterval v = "2010-03 - 31 T 15: 00Z / 2010-03 - 31 T 16: 00Z" / >
    < MeasureUnitQuantity v = "MAW" / >
    < v currency = "EUR" / >
    < MeasureUnitPrice v = "MWH" / >
    < v direction = "A01" / >
    < MinimumActivationQuantity v = "50" / >
    < v status = "A06" / >
    < period >
    < v TimeInterval = "2010-03 - 31 T 15: 00Z / 2010-03 - 31 T 16: 00Z" / >
    < resolution v = "PT60M" / >
    <>interval
    < v pos = "1" / >
    < v Qty = "50" / >
    < character v = "17.0" / >
    < / interval >
    < / period >
    < / MolTimeSeries >
    < / MolDocument >

    Hello

    The result I got was:

    16RTE_20100331_1500_20NG_20100331_1500_6

    In the query have you tried, access you a single record if you can not expect to get three rows of "magic". The EXTRACT function works as planned, it retrieves the nodes required, but the result is always a fragment of XML (a scalar value).
    To achieve your goal, you must divide the sequence MolTimeSeries in relational lines.

    Two similar solutions are possible, XMLTable (10gr 2 and more) or Table/XMLSequence.
    In your other post, you mentioned db version 10.1, so I guess we go with XMLSequence:

    SELECT 'RTE'
           ,to_date(substr(extractvalue(x.xml_data,'/MolDocument/ValidTimeInterval/@v'),1,16),'yyyy-mm-dd"T"hh24:mi')
           ,decode(extractvalue(x2.column_value,'/MolTimeSeries/Direction/@v'),'A01','Up','Down')
           ,to_number(regexp_substr(extractvalue(x2.column_value,'/MolTimeSeries/ContractIdentification/@v'),'\d+$'))
           ,to_number(extractvalue(x2.column_value,'/MolTimeSeries/Period/Interval/EnergyPrice/@v'))
           ,sysdate
           ,null
           ,null
           ,extractvalue(x2.column_value,'/MolTimeSeries/ContractIdentification/@v')
           ,'SUBMITTED'
           ,'A96'
           ,null
           ,sysdate
    FROM xml_demo x,
         table(
           xmlsequence(
             extract(x.xml_data, '/MolDocument/MolTimeSeries')
           )
         ) x2
    WHERE existsnode(x.xml_data,'/MolDocument/DocumentIdentification[@v="MOL_20100331_1500_1600"]') = 1;
    

    Also note the use of instead of the ordinary SUBSTR REGEXP_SUBSTR because he has not worked for "NG_20100331_1500_6".

    Hope that helps.

    Published by: odie_63 on June 24, 2010 21:18 - comment added regexp

Maybe you are looking for

  • Cannot select folder to add bookmark

    Opened a new site in a tab. Click on the bookmarks menu, then bookmark this Page. Window opens and I click on the file selection cursor. Displays the list of files, but I can't scroll or select any folder, so I click done and then go to all bookmarks

  • Where can I find Version 4

    I need to be able to report our website QA work does not on FF4

  • DVD - RAM drive on a Satellite Pro M40 with MS Vista Business

    HelloI updated my MS Vista operating system now that it has been launched. Everything works fine, except on my CD player. I've not managed to get a driver so can't read music and DVDs. I would appreciate any advice you can offer with this. Kind regar

  • Satellite P10 turn suddenly

    Hello I have the satellite P10Im having problems.I reformatted about a month ago, and since then, his performance is even more strange. One morning, I turned on and then as windows was loading, all images on the screen pixeld and started jumping up a

  • ehExtHost.exe error in Windows Media Center.

    Original title: Media Center Error Message. I get an error of ehExtHost.exe when I start media Center on my computer running Windows XP.  It is said that a registered JIT debugger is not available.  When I click on cancel he says that there is an err