Group by Parent with Child Records

Basically i have three Tables 
Request ID   Parent ID   Account Name   Addresss 
1452         1254789     Wendy's        Atlanta Georgia 
1453         1254789     Wendy's        Norcross Georgia
1456         1254789     Waffle House   Atlanta Georgia
Bid_ID       Bid_Type    Bid_Volume   Bid_V   Bid_D  Bid_E  Request_ID  Parent ID                 
45897        Incentive    10                 N/A     N/A       N/A     1452        1254789
45898        Incentive    10                 N/A     N/A       N/A     1453        1254789
45899        Incentive    10                 N/A     N/A       N/A     1456        1254789
Bid_Number     Bid_Name    Request_ID  Parent ID
Q789456       Wendy'Off     1452       1254789
Q789457       Wendy'Reba    1452       1254789
Q789456       Wendy'Off     1453       1254789
Q789457       Wendy'Reba    1453       1254789
Q789456       Wendy'Off     1456       1254789
I want the Result 
Parent ID   Bid_Type    Bid_Volume   Bid_V   Bid_D  Bid_E  AutoGeneratedCol
1254789     Incentive    10                  N/A     N/A      N/A      1
 1254789    Incentive    10                  N/A     N/A      N/A      2
Bid Number  AutoGeneratedCol_Link
Q789456       1
Q789457       1 
Q789456       2
Request ID  AutoGeneratedCol_Link
1452          1
1453          1
1456          2
In the above example Group parent with respect to child information .If all the Bid numbers are same (even number count) and Bid details same then group that request as one .
then same Bid number but other Bid number is not present then group into other 
Like similar example the number of bids may vary and bid numbers may vary 

I was expecting below results .
Group By Child tables i.e. AccountBids,AccountBidInformation
AccountBidInformation will be one to one relationship with AccountTable table 
AccountBids will be one to many relationship with AccountTable
During Group by AccountBidInformation will have one record and AccountBids are combined with budnumber is one column
Select distinct GSR,CustomizedClaims,TotalWeeklyVolume,ParentOrVendor,PP,CWT,(Select top 1 
substring(
Select ','+ST1.BidNumber  AS [text()]
From dbo.AccountBids ST1
Where ST1.AccountTable_ID = ST2.AccountTable_ID--Combine Bids to one row with respect to reference Key 
ORDER BY ST1.BidNumber
For XML PATH ('')
), 2, 1000) [Bids]
From dbo.AccountBids ST2 WHERE ST2.AccountTable_ID = AccountBids.AccountTable_ID) 
FROM AccountBids
INNER JOIN AccountBidInformation On AccountBids.AccountTable_ID = AccountBidInformation.AccountTable_ID 
ORDER BY GSR,CustomizedClaims,TotalWeeklyVolume,ParentOrVendor,PP,CWT
 After grouping AccountBids,AccountBidInformation .Select AccountTable records for each group by record 
SELECT Main.Account_Number,Effective_Date,Details FROM AccountTable Main
 INNER JOIN AccountBids ON AccountBids.AccountTable_ID = Main.AccountTable_ID
 INNER JOIN AccountBidInformation ON AccountBidInformation.AccountTable_ID = Main.AccountTable_ID
WHERE BidNumber in ('P120012','P120014')--First Record from previous select 
AND TotalWeeklyVolume = 452  --First Record from previous select 
AND ParentOrVendor = 'P' --First Record from previous select 
AND PP = 'N/A' --First Record from previous select 
AND CWT = 'N/A' --First Record from previous select 
Exists make sure Number of bids remain same 
Example : If you remove Exists then Second below query will return two duplicate record which is already selected in this .
AND EXISTS(
SELECT  AccountTable_ID          --           
FROM    AccountBids SUB            --          
WHERE   Main.AccountTable_ID = SUB.AccountTable_ID
GROUP   BY AccountTable_ID
HAVING  COUNT(*) = 2 --Pass number of bids selected from first result w.r.t commo seperated 
GROUP BY Main.Account_Number,Effective_Date,Details having count(BidNumber) = 2
SELECT Main.Account_Number,Effective_Date,Details FROM AccountTable Main
 INNER JOIN AccountBids ON AccountBids.AccountTable_ID = Main.AccountTable_ID
 INNER JOIN AccountBidInformation ON AccountBidInformation.AccountTable_ID = Main.AccountTable_ID
WHERE BidNumber in ('P120012')AND 
TotalWeeklyVolume = 452 
AND ParentOrVendor = 'P'
AND PP = 'N/A'
AND CWT = 'N/A' AND 
EXISTS(
SELECT  AccountTable_ID          --           
FROM    AccountBids SUB            --          
WHERE   Main.AccountTable_ID = SUB.AccountTable_ID
GROUP   BY AccountTable_ID
HAVING  COUNT(*) = 1 
GROUP BY Main.Account_Number,Effective_Date,Details having count(BidNumber) = 1
SELECT Main.Account_Number,Effective_Date,Details FROM AccountTable Main
 INNER JOIN AccountBids ON AccountBids.AccountTable_ID = Main.AccountTable_ID
 INNER JOIN AccountBidInformation ON AccountBidInformation.AccountTable_ID = Main.AccountTable_ID
WHERE BidNumber in ('P120012','P120014')
AND TotalWeeklyVolume = 453 
AND ParentOrVendor = 'N'
AND PP = 'N/A'
AND CWT = 'N/A'
AND EXISTS(
SELECT  AccountTable_ID          --           
FROM    AccountBids SUB            --          
WHERE   Main.AccountTable_ID = SUB.AccountTable_ID
GROUP   BY AccountTable_ID
HAVING  COUNT(*) = 2 
GROUP BY Main.Account_Number,Effective_Date,Details having count(BidNumber) = 2

Similar Messages

  • Query to delete both parent and child record....

    hai.........
    I tried to delete a record from the table.... but i get a error saying 'child record' exist cannot delete record'.... can u plz tell me the query to delete both parent and child record....
    plz help me.....
    anoo...

    Hello,
    Is already answered in {thread:id=824593}. Please mark the question as answered.
    Greetings,
    Roel
    http://roelhartman.blogspot.com/
    http://www.bloggingaboutoracle.org/
    http://www.logica.com/

  • How to delete parent and child records?

    Hi friends,
    I have a Master table and a child table.
    The Child table got reference key with the master table without on delete cascade.
    Now, I want to delete the Master records and also it's corresponding child records.
    How to do?
    Thanks in adv,
    regards,
    Vijay

    Delete the records from the child, then delete the records from the parent in two separate delete statements. I'd prefer that you create a stored procedure that does both steps.
    Justin

  • Join parent with child on nested object table

    We made a nested table in Oracle 8i with two object types and collection type.
    We manipulating with it - no problem.
    However trying to join parent with the child cause the problem in PL/SQL
    This sintax is OK for Oracle SQL and returns right result:
    select
    matl.barcode_id,
    matl.LAST_MOD_TSP,
    dtl.matl_nbr,
    bmm.matl_dsc,
    dtl.asn_qty,
    dtl.mfg_dt
    from
    asn_barcode_matl_ot matl,
    table(matl.asn_barcode_matl_dtl) dtl,
    wms_brwy_matl_mstr bmm
    where
    matl.rcpt_seq_id = 1
    and matl.brwy_cd = bmm.brwy_cd
    and dtl.matl_nbr = bmm.matl_nbr;
    But stored procedure with this statement doesn't compile and giving the error:
    PLS-00201: identifier 'MATL.ASN_BARCODE_MATL_DTL' must be declared
    Looks like a bug? What is wrong?

    It is not possible. You can do this with trigger code, or preferably by adjusting your delete procedure api. A delete of the master record will often fail because other children records exists, so you have to catch that exception and do something that is useful to you in this situation.
    Regards,
    Rob.

  • How to delete parent and child records together ?

    Hi,
    I'm using Jdeveloper 11.1.2.2
    I want to delete a row from a table but it is showing: Caused by: java.sql.SQLIntegrityConstraintViolationException: ORA-02292: integrity constraint (TABLE1_TL_FK1) violated - child record found.So how can I delete a Child row and table row in one method ?
    I cannot access the child's VO because it is not added to the AM.
    Thanks,
    Nigel.

    John, as usually, is right with the pointer to the documentation he pasted. Just to make sure you read it carefully, let me hoghlight an important point here:
    "If the option is selected, then the composed entities do not perform the DELETE statement *on the assumption that the database ON DELETE CASCADE constraint will handle the deletion of the corresponding rows*."
    So make sure the database is setup for cascade delete as otherwise you still will not succeed
    Frank

  • Deleting rows with child records

    Hi,
    I want to delete some records from master table based on where condition. But I want all the corresponding child record should also delete from the respective child tables..
    Can anyone tell me how to go about it with example( eg emp & dept table of scotts)
    Regards

    I have been to slow for posting...
    Please note that I hate doing this
    SCOTT@LSC01> select count(*) from emp;
      COUNT(*)
            14
    SCOTT@LSC01> delete dept where deptno=10;
    <font color=red>1 row deleted.</font>
    SCOTT@LSC01> select count(*) from emp;
      COUNT(*)
            11the risk is that someone is not aware of deleting rows, and instead of getting
    SCOTT@LSC01> delete dept where deptno=10;
    delete dept where deptno=10
    ERROR at line 1:
    ORA-02292: integrity constraint (SCOTT.FK_DEPTNO) violated - child record foundhe is deleting rows in other tables and will never be aware of that deletion ...

  • How to give filter condition in expdp to filter parent and child records?

    Hi,
    I have a requirement of export schema. Assume there is a account details table and account transactions table under schema.They have parent child relation exist. if i filter accounts from account details the corresponding transactions in account transactions table should be filterd.How to achieve this?
    Regards,
    Venkat Vadlamudi
    Mobile:9850499800

    Try with USER_DEPENDIENCIES
    select * from user_dependencies

  • Union on tables with parent-child records and Sorting

    Hi,
    I have an application that has an existing query which returns org units (parent and child) from organization table with a sort on createddate +  org_id combination
    WITH Org_TREE AS (
    SELECT *, null as 'IS_DELETED', convert (varchar(4000), convert(varchar(30),CREATED_DT,126) + Org_Id) theorderby
    FROM Organization WHERE PARENT_Org_ID IS NULL and case_ID='43333'
    UNION ALL
    SELECT a1.*, null as 'IS_DELETED', convert (varchar(4000), a2.theorderby + convert(varchar(30),a1.CREATED_DT,126) + a1.Org_Id)
    FROM Organization a1 INNER JOIN Org_TREE a2 ON a1.PARENT_Org_ID = a2.Org_Id and case_ID='43333'
    SELECT * FROM Org_TREE order by theorderby
    I have created a new log table for organization 'Organization_Log' with exact columns as Organization table with an additional 'IS_DELETED' bool column.
    Questions:
    I need to modiy the query,
    1. To display the parent and child records both from the organization table and organization_log table.
    2. the sort on the result should be based on 'Organization Name' column asc. First with parent org and the child org underneath it. For eg.
    aaa
    ==>fff
    ==>ggg
    bbb
    ==> aaa
    ==> hhh
    Any help on how the query should be constructed?
    Thanks
    gkol

    @Visakh16,
    I am getting...
    All queries combined using a UNION, INTERSECT or EXCEPT operator must have an equal number of expressions in their target lists.
    The problem is that you will have different number of columns in both log and Organization and Organizationlog tables. UNION/UNION ALL expect the same number of columns.
    Try the below:
    WITH Org_Log_TREE AS (
    SELECT Organization_name,Org_id,Parent_Org_id, IS_DELETED, CAST(Organization_Name AS varchar(max)) AS theorderby,1 AS level
    FROM Organization_Log WHERE PARENT_Org_ID IS NULL and case_ID='43333'
    UNION ALL
    SELECT a1.Organization_name,a1.Org_id,a1.Parent_Org_id, a1.IS_DELETED, CAST(a2.theorderby +'/' + CAST(a1.Organization_Name AS varchar(1000)) AS varchar(max)),a2.Level + 1
    FROM Organization_Log a1 INNER JOIN Org_Log_TREE a2 ON a1.PARENT_Org_ID = a2.Org_Id and case_ID='43333'
    ) ,Org_TREE AS (
    SELECT Organization_name,Org_id,Parent_Org_id, NULL AS IS_DELETED, CAST(Organization_Name AS varchar(max)) AS theorderby,1 AS level
    FROM Organization WHERE PARENT_Org_ID IS NULL and case_ID='43333'
    UNION ALL
    SELECT a1.Organization_name,a1.Org_id,a1.Parent_Org_id,NULL AS IS_DELETED, CAST(a2.theorderby +'/' + CAST(a1.Organization_Name AS varchar(1000)) AS varchar(max)),a2.Level + 1
    FROM Organization a1 INNER JOIN Org_TREE a2 ON a1.PARENT_Org_ID = a2.Org_Id and case_ID='43333'
    SELECT * FROM Org_Log_TREE
    UNION ALL
    SELECT * FROM Org_TREE
    ORDER BY LEFT(theorderby,CHARINDEX('/',theorderby + '/')-1),Level

  • Hierarchy query showing  parent and their child records

    I'm a newbie on Oracle using Tora,
    I'm Trying to run a query that will show me a hierarchical view of parent and child records in a table.
    So far I"ve found a query format like this, but its not working
    SELECT employee_id, last_name, manager_id
    FROM employees
    CONNECT BY PRIOR employee_id = manager_id;
    but when running it with my tables and columns I get an error message
    saying something 'cannont run CONNECT BY in subquery'
    Any ideas?

    Thanks for all the help, I'm getting the error message
    'ORA-01473: cannot have subqueries in CONNECT BY clause'
    Here's my actual query
    select           resource_id, lname, org_id
    from           std_resource
    start with      resource_id = 413783
         connect by prior resource_id = org_id;
    I'm trying to display a hierarchical list of user resource_id's, last names, and org_id's from the std_resource table starting withe resource_id 413783

  • How to delete the child record from the database

    how to delete a parent and child record from the database can we do it in the servlet and my database is oracle

    I'm not sure I understand the question but you could certainly use the JDBC API from within your servlet to access and modify a DB. You could also use an EJB layer to access your DB and accomplish the same tasks.

  • Query to fetch child of child records of a given party

    Hi,
    We have requirement to fetch the child records(child of child records also) of a given party name.
    We had written the below query:
    SELECT distinct hp.party_name
    FROM hz_parties hp,
    hz_relationships hzr,
    hz_parties hp2
    WHERE hzr.direction_code = 'C'
    AND hp.party_id = hzr.subject_id
    AND hzr.object_id = hp2.party_id
    AND relationship_type ='Parent-Child Hierarchy'
    --'Org Structure'
    --'Parent-Child Hierarchy'
    AND hz_utility_v2pub.get_lookupmeaning
    ('AR_LOOKUPS',
    'PARTY_RELATIONS_TYPE',
    hzr.relationship_code
    ) = 'Child of'
    AND hp2.party_name = :P_CUSTOMER
    This query fetches only one level of parent and child records.
    Please help us in fetching the child of child records also. We tried using 'Connect By', but its not working as expected.
    Thanks in advance.

    Hi,
    We have requirement to fetch the child records(child of child records also) of a given party name.
    We had written the below query:
    SELECT distinct hp.party_name
    FROM hz_parties hp,
    hz_relationships hzr,
    hz_parties hp2
    WHERE hzr.direction_code = 'C'
    AND hp.party_id = hzr.subject_id
    AND hzr.object_id = hp2.party_id
    AND relationship_type ='Parent-Child Hierarchy'
    --'Org Structure'
    --'Parent-Child Hierarchy'
    AND hz_utility_v2pub.get_lookupmeaning
    ('AR_LOOKUPS',
    'PARTY_RELATIONS_TYPE',
    hzr.relationship_code
    ) = 'Child of'
    AND hp2.party_name = :P_CUSTOMER
    This query fetches only one level of parent and child records.
    Please help us in fetching the child of child records also. We tried using 'Connect By', but its not working as expected.
    Thanks in advance.

  • Deleting parent record with child instances

    Is there a way i can delete records from the database when i have one of the columns being used in other tables.
    Eg: m_id used in tables meter ( Primary key ) and period_meter( foreign key) and site_area_meter (foreign key). I want to delete record whose m_id is so and so...
    if not then any other idea to discard that parent , child records
    thanks in advance

    I was able to solve my problem by using the item tag to the Navigate Tree: Get Parent invoke node and then wiring through the item to the next item tag as needed.
    I attached a screen shot.
    Kenny
    Kenny
    Attachments:
    get items from tree control.gif ‏4 KB

  • Fastest way to find parents with only one child?

    I have two very large tables (both >6 million rows) in an oracle 8i DB. They have a parent child relationship and I would like to construct a query to give me the parents that have only one child......syntactically, what's the best way to construct this query?
    I was going to try:
    select join_id
    FROM parent
    where join_id in (select join_id, count(join_id)
    FROM child
    group by join_id
    having count(*)=1)
    but then I realized that the subselect has two columns to return and the primary query is only expecting one column, so this will not work.
    I suspect there's a quick and dirty way to find out what parents have only one child....
    I thought of using rowid's but am not sure this is the best way and in the example below I tried, I'm having problems b/c of functions not being allowed in the where clause.....
    select join_id
    from child d
    where rowid in (select min(rowid)
              FROM child s
              WHERE min(d.rowid)=max(s.rowid)
              AND s.join_id=d.join_id))
    Any thoughts?

    The two tables are order_header and order_detail. The order_header carries order specific information and the detail contains item specific information.
    So if you had ordered three separate products, you would have:
    one row in the order_header table (parent)
    and three rows in the order_detail table (child)
    They are linked by order_number.
    I presented the problem this way to make it more accessible to more posters.....;)
    One possible solution that I've thought of for my problem is this:
    select join_id
    from child_table d
    where (d.rowid, d.rowid) IN (select min(rowid) MIN_ROW
                   ,max(rowid) MAX_ROW
                   FROM child_table
                   WHERE s.str_order_number=d.str_order_number
                   AND s.date>='30-JAN-2005'
                   AND s.date<='31-JAN-2005'))
    I think this might work because I think that we can safely assume that if the minimum rowid and the maximum rowid (with the same join_id ) are the same then there is only one child record.....is this logic correct?

  • Inserting parent /child records from a xml file ...

    XML file pasted below:
    I have loaded the xml file into a table called xml_demo which has a column xml_data of type xmltype.
    The select for parent record is as follows 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"T"hh24:mi')
    ,123456
    ,'CREATED',
    NULL
    FROM xml_DEMO x WHERE
    existsnode(x.xml_data,'/MolDocument/DocumentIdentification[@v="MOL_20100331_1500_1600"]') = 1)
    Having problem creating child records. From this file I expect to create 3 records.
    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 'RTE'
    ,to_date(substr(extract(x.xml_data,'/MolDocument/ValidTimeInterval/@v'),1,16),
    'yyyy-mm-dd"T"hh24:mi')
    ,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 pounds
    ,null -- price euro
    ,extract(x.xml_data,'/MolDocument/MolTimeSeries/ContractIdentification/@v')
    ,'SUBMITTED'
    ,'A96'
    ,NULL -- acquiring area
    ,sysdate
    FROM xml_DEMO x WHERE
    existsnode(x.xml_data,'/MolDocument/DocumentIdentification[@v="MOL_20100331_1500_1600"]') = 1)
    For example, there are 3 ContractIdentification tags. Example of 1:
    <ContractIdentification v="RTE_20100331_1500_16"/>
    I was expecting this select to pluck the last number from this string. In this case 16.
    The select 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 contractident values are concatnated and returns from position 19 onwards.
    Can anyone help me to extract the last number from each ContractIdentification tag value and to create the 3 records
    Thanks
    James Sathiaraj
    <?xml version="1.0" encoding="UTF-8"?>
    <MolDocument DtdVersion="3" DtdRelease="0">
    <DocumentIdentification v="MOL_20100331_1500_1600"/>
    <DocumentVersion v="1"/>
    <DocumentType v="A43"/>
    <SenderIdentification codingScheme="A01" v="17X100Z100Z0001H"/>
    <SenderRole v="A35"/>
    <ReceiverIdentification codingScheme="A01" v="10XFR-RTE------Q"/>
    <ReceiverRole v="A04"/>
    <CreationDateTime v="2010-03-31T14:10:00Z"/>
    <ValidTimeInterval v="2010-03-31T15:00Z/2010-03-31T16:00Z"/>
    <Domain codingScheme="A01" v="10YDOM-1001A001A"/>
    <MolTimeSeries>
    <ContractIdentification v="RTE_20100331_1500_16"/>
    <ResourceProvider codingScheme="A01" v="10XFR-RTE------Q"/>
    <AcquiringArea codingScheme="A01" v="17Y100Z100Z00013"/>
    <ConnectingArea codingScheme="A01" v="10YFR-RTE------C"/>
    <AuctionIdentification v="AUCTION_20100331_1500_1600"/>
    <BusinessType v="A10"/>
    <BidTimeInterval v="2010-03-31T15:00Z/2010-03-31T16:00Z"/>
    <MeasureUnitQuantity v="MAW"/>
    <Currency v="EUR"/>
    <MeasureUnitPrice v="MWH"/>
    <Direction v="A02"/>
    <MinimumActivationQuantity v="50"/>
    <Status v="A06"/>
    <Period>
    <TimeInterval v="2010-03-31T15:00Z/2010-03-31T16:00Z"/>
    <Resolution v="PT60M"/>
    <Interval>
    <Pos v="1"/>
    <Qty v="50"/>
    <EnergyPrice v="50.45"/>
    </Interval>
    </Period>
    </MolTimeSeries>
    <MolTimeSeries>
    <ContractIdentification v="RTE_20100331_1500_20"/>
    <ResourceProvider codingScheme="A01" v="10XFR-RTE------Q"/>
    <AcquiringArea codingScheme="A01" v="17Y100Z100Z00013"/>
    <ConnectingArea codingScheme="A01" v="10YFR-RTE------C"/>
    <AuctionIdentification v="AUCTION_20100331_1500_1600"/>
    <BusinessType v="A10"/>
    <BidTimeInterval v="2010-03-31T15:00Z/2010-03-31T16:00Z"/>
    <MeasureUnitQuantity v="MAW"/>
    <Currency v="EUR"/>
    <MeasureUnitPrice v="MWH"/>
    <Direction v="A02"/>
    <MinimumActivationQuantity v="50"/>
    <Status v="A06"/>
    <Period>
    <TimeInterval v="2010-03-31T15:00Z/2010-03-31T16:00Z"/>
    <Resolution v="PT60M"/>
    <Interval>
    <Pos v="1"/>
    <Qty v="50"/>
    <EnergyPrice v="50.48"/>
    </Interval>
    </Period>
    </MolTimeSeries>
    <MolTimeSeries>
    <ContractIdentification v="NG_20100331_1500_6"/>
    <ResourceProvider codingScheme="A01" v="10X1001A1001A515"/>
    <AcquiringArea codingScheme="A01" v="17Y100Z100Z00013"/>
    <ConnectingArea codingScheme="A01" v="10YGB----------A"/>
    <AuctionIdentification v="AUCTION_20100331_1500_1600"/>
    <BusinessType v="A10"/>
    <BidTimeInterval v="2010-03-31T15:00Z/2010-03-31T16:00Z"/>
    <MeasureUnitQuantity v="MAW"/>
    <Currency v="EUR"/>
    <MeasureUnitPrice v="MWH"/>
    <Direction v="A01"/>
    <MinimumActivationQuantity v="50"/>
    <Status v="A06"/>
    <Period>
    <TimeInterval v="2010-03-31T15:00Z/2010-03-31T16:00Z"/>
    <Resolution v="PT60M"/>
    <Interval>
    <Pos v="1"/>
    <Qty v="50"/>
    <EnergyPrice v="17.0"/>
    </Interval>
    </Period>
    </MolTimeSeries>
    </MolDocument>

    Hi,
    The result I got was:
    16RTE_20100331_1500_20NG_20100331_1500_6In the query you tried, you access a single record so you can't expect to get three rows "magically". The EXTRACT function just works as expected, it extracts the requested nodes, but the result is still an XML fragment (a scalar value).
    In order to achieve your goal, you have to break the MolTimeSeries sequence into relational rows.
    Two similar solutions are possible, XMLTable (10gR2 and up) or Table/XMLSequence.
    In your other post you mentioned db version 10.1, so I guess we'll 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;Please also note the use of REGEXP_SUBSTR instead of the regular SUBSTR because it didn't work for "NG_20100331_1500_6".
    Hope that helps.
    Edited by: odie_63 on 24 juin 2010 21:18 - added regexp comment

  • How to get the parent and child relation of the group (______________)

    Please teach the method of acquiring the parent and child relation of the group with EDK5.2.
    EDK5.2____________________,_________o

    Hello.
    Java________,_______________...
    Class________o
    com.plumtree.remote.auth.ChildGroupList
    ...o(^^;)
    Best Regards,
    --------- Hiroko Iida_______ (05/10/28 18:27) -------
    Please teach the method of acquiring the parent and child relation of the group with EDK5.2.
    EDK5.2____________________,_________o

Maybe you are looking for

  • What is best way to move pictures from laptop to EHD pse10

    I have gotten differing views on the best way to move my pictures from my laptop (to free up space) to an EHD while keeping PSE10 on my computer.  When I want to do something in PSE10 I would connect my EHD. It has been suggested to follow the pse10

  • Read receipt in snow leopard mail...

    I am relatively new to mac and mail.  can anyone please help me with delivery receipts and read receipts like one can get from those awful windows applications?

  • How do you overlap PDF's and finish with one PDF file? Need help ASAP

    how do you overlap PDF's and finish with one PDF file? Need help ASAP

  • JMS SAF client paging directory definition ignored

    The paging directory definition in our ClientSAF.xml file is ignored:           <weblogic-client-jms xmlns="http://www.bea.com/ns/weblogic/90" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">           <persistent-store>                <directo

  • J2me sdk 3.0  problems in System.out.print

    Hi I can not use println to print Chinese . First I just use System.out.print("test") to print some debug information , and I surprised to find it print nothing. Then I try System.out.println("test") and it worked well. But there still problem when p