XML from the master-child tables

Hello

Just post here again for a quick response.

XML from the master-child tables


Best regards
Hari

Hello

Using SQL/XML functions is the way to go in this case.

SQL> select xmlroot(
  2           xmlelement("ROWSET",
  3             xmlagg(
  4               xmlelement("MASTER",
  5                 xmlforest(tm.master_id, tm.master_name, tm.master_location),
  6                   (
  7                    select xmlagg(
  8                             xmlelement("CHILD",
  9                               xmlforest(tc.child_id, tc.child_name, tc.child_location)
 10                             ) order by tc.child_id
 11                           )
 12                    from t_child tc
 13                    where tc.master_id = tm.master_id
 14                   )
 15               ) order by tm.master_id
 16             )
 17           )
 18         , version '1.0')
 19  from t_master tm
 20  where tm.master_id = 1
 21  ;

XMLROOT(XMLELEMENT("ROWSET",XM
--------------------------------------------------------------------------------


  
    1
    master name
    master location
    
      1
      child name 1
      child location 1
    
    
      2
      child name 2
      child location 2
    
    
      3
      child name 3
      child location 3
    
  

 

Note that the first XMLAgg is optional here, since you want just a MASTER at a time.
But if you need an XML document containing several masters, he will work as well.

Alternatively, you can write a similar query with a GROUP BY clause (no correlated subquery, but a join between the master and the child instead):

select xmlroot(
         xmlelement("ROWSET",
           xmlagg(
             xmlelement("MASTER",
               xmlforest(tm.master_id, tm.master_name, tm.master_location),
                 xmlagg(
                   xmlelement("CHILD",
                     xmlforest(tc.child_id, tc.child_name, tc.child_location)
                   ) order by tc.child_id
                 )
             ) order by tm.master_id
           )
         )
       , version '1.0'
       )
from t_master tm
     join t_child tc on tc.master_id = tm.master_id
where tm.master_id = 1
group by tm.master_id, tm.master_name, tm.master_location
;

Published by: odie_63 on June 15, 2011 15:06

Tags: Database

Similar Questions

  • How to create multiple hierarchies from the same physical table

    Hi all

    I have a physical table to join with a fact table: there are 3 different hierarchies, which share the last 2 levels inside the dimension table. It's the logic diagram of hierarchies:

    Dimension services
    -Business
    -Sector
    -Type
    -Operator
    -Product
    Partner of dimension
    -Partner
    -Operator
    -Product
    Contractor of dimension
    -Contractor
    -Operator
    -Product

    All columns are in the same table physical source. I tried to create 3 table logic source from the same physical table, everyone with all the columns and create a hierarchy for each dimension table, but it gives me nQSError: 15011.

    Any suggestion? Maybe the physical table alias can help for the creation of tables of different sizes?

    Thanks in advance,
    Concerning

    Hello

    It is a basic rule that you cannot create multiple hierarchies in a single dimension table, so what you do is create three tables of alias and slip into MDB layer in 3 different sizes and on top these tables create 3 different dimension hierarchies.

    Check if useful/correct

    Thank you.

  • XML from the Oracle Table data

    Hi all

    I'm new to this network. I'm also new to oracle XML package. I want a help with the query below.

    CREATE TABLE EMP (ID NUMBER PRIMARY KEY, NAME VARCHAR2 (10), TELEPHONE NUMBER);

    INSERT INTO EMP (ID, NAME, PHONE) VALUES (11, 'Joy', 1234);
    INSERT INTO EMP (ID, NAME, PHONE) VALUES (22, 'Mike', 5678).
    INSERT INTO EMP (ID, NAME, PHONE) VALUES (33, "Jason", NULL);
    COMMIT;

    I want to export data from the EMP table in an XML file with the format below.

    Power required:

    <? XML version = "1.0" encoding = "UTF-8"? > < Joy STATICDATA > < EMP > < ID > 11 < /ID > < NAME > < / NAME > < / EMP > < / STATICDATA >
    <? XML version = "1.0" encoding = "UTF-8"? > < Mike STATICDATA > < EMP > < ID > 22 < /ID > < NAME > < / NAME > < / EMP > < / STATICDATA >
    <? XML version = "1.0" encoding = "UTF-8"? > < Jason STATICDATA > < EMP > < ID > 33 < /ID > < NAME > < / NAME > < / EMP > < / STATICDATA >

    I used some XML functions and you wrote the following query.

    Select XMLROOT (XMLELEMENT (staticdata, XMLELEMENT (EMP, XMLELEMENT(ID,ID), XMLELEMENT(NAME,NAME))), version "1.0" encoding = "UTF - 8') xml EMP;

    my query output:

    <? XML version = "1.0" encoding = "UTF-8"? >
    < STATICDATA >
    < EMP >
    < ID > 11 / < ID >
    Joy of < NAME > < / NAME >
    < / EMP >
    < / STATICDATA >
    <? XML version = "1.0" encoding = "UTF-8"? >
    < STATICDATA >
    < EMP >
    < ID > 22 / < ID >
    < NAME > Mike < / NAME >
    < / EMP >
    < / STATICDATA >
    <? XML version = "1.0" encoding = "UTF-8"? >
    < STATICDATA >
    < EMP >
    < ID > 33 / < ID >
    Jason < NAME > < / NAME >
    < / EMP >
    < / STATICDATA >


    But I want the out as the power required above. all records in a single line. can someone help me achieve the desired output. also can I export all columns of the table with something like select * from the table in the XML file?

    Thank you
    Delobelle

    Don't know why you need it on a single line, but you could:

    Select XMLTYPE (REGEXP_REPLACE (XMLROOT (XMLELEMENT (staticdata, XMLELEMENT (EMP, XMLELEMENT(ID,ID), XMLELEMENT(NAME,NAME))), version "1.0" encoding = "UTF - 8'), CHR (10) |)) ' *<><'))>
    FROM EMP;

    SY.

  • Task flow train bounded with new transaction to add to the master-detail table

    JDeveloper 11 g 11.1.1.0.2
    ADF BC
    ADF RC

    When I implemented workflows task train bounded to add line to the main table and two-step
    first step and first page insert the info from the main table as model of information
    second stage and second page to insert a line in the secondary table as emp info

    I get the error:

    Messages for this page are listed below.
    Constraint "EMP_COMP_FK1" violated during the post operation: 'Insert' with SQL statement ' BEGIN INSERT INTO EMP (EMP_ID, PERSON_ID, COMP_ID, JOB, CONTACT_FLAG, BILL_FLAG, STATUS, CREATED_BY, CREATED_DATE, UPDATED_BY, UPDATED_DATE) VALUES (: 1,: 2,: 3,: 4,: 5,: 6,: 7,: 8: 9,: 10,: 11) in RETURNING EMP_ID INTO: 12; END; ».
    ORA-02291: integrity constraint (DB1. EMP_COMP_FK1) violated - key parent not found
    ORA-06512: at line 1


    I think that this error occurs when trying to insert in master and detail in the same transaction, but what is the solution for my case?

    Note:
    I don't want to use the strong association when define the relationship master detail

    Concerning
    Zuhair

    Zuhair,

    Have a reading of article 34.8 Fusion developer Guide - he talks about how to control the display order as the parent is always inserted before the child - it does indeed sound like this is the cause of your problem.

    John

  • How to join two tables to retrieve the data from the columns in table two. Tables have primary and foreign key relationships

    Hello

    I want to join the two tables to retrieve the data from the columns of the two table passing parameters to the join query. Tables have primary and foreign key relationships

    Details of the table

    Alert-1 - AlertCode (FK), AlerID (PK)

    2 AlertCode-AlertDefinition-(PK)

    Help, please


    ----------

    Hi Vincent,.

    I think that you have not worked on adf 12.1.3.  In adf 12.1.3 you don't have to explicitly create the association. When you create the EO to your table, Association xxxxFkAssoc, will be created by ADF12.1.3 for you automatically. Please try this and do not answer anything... You can also follow the links below. I solved the problem by using the following link

    Oracle ADF Guide step by step - Oracle ADF tutorial: creating a relationship of the master / detail using Oracle ADF

    ---

  • The changes have disappeared from the master page, why?

    Changes in the master page of a dita topic file, but whenever I restart FrameMaker2015, any changes disappear, why? Everyone please answer!

    Adama

    mehjabins,

    The appearance of a file of DITA topic, including master pages, comes from a model when the XML source file is opened. Then when the XML file is saved, the information disappears. In other words, all information of formatting in a file in FrameMaker DITA is temporary, just a convenience for the creation of WYSIWYG. If you want the master page changes to stay permanent, you need to change the common model that is used to open files. If change you it, the changes appear in every theme DITA file that you open then.

    I don't know exactly where this file remains, perhaps someone else could give advice. I would say, however, that this can be a risky business. Be sure to make backups.

    Russ

  • 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

  • LWcfg.xml from the directory profile hidden during loading of FSX.

    When I try to load FSX I get an error message that says remove LWcfg.xml in the hidden user profile directory. I have run the repair for the program and reinstalled FSX, but I still get the error. Where the file is located and how do I remove it.

    Hello Michael,

    Thanks for posting your question on the forum of the Microsoft community.

    I suggest you to ask your question on the forums and the support of Flight Simulator.

    See this link:
    http://www.Microsoft.com/products/games/FSInsider/tips/pages/default.aspx

    You can also try to uninstall Flight Simulator X from your computer and try to reinstall and see if the problem is resolved.
     
    Download AND install the Windows Installer Cleanup from here utility:

    http://support.Microsoft.com/kb/290301
     
    Open the Windows Installer Cleanup utility from the menu START. Should be found in:

    START > Windows Install Cleanup.

    Look for the FSX entry in the list, select it and remove it.

    1. click on START.
    2. click on "Control Panel"...
    3. click on "Folder Options".
    4. uncheck the "hide hidden files & folders".
    5. click on 'Apply' at the bottom right.
    6. close all windows.
    7. click on START.
    8. click on 'computer '.
    9. click on "Local disk (c :))".
    10 go in Program Files\Microsoft Games\Flight Simulator X.
    11. If there is any files, delete them.
    12. then, go back one folder and delete the Flight Simulator X folder.

    13. Once this is done, close all programs, restart the computer and then try to reinstall the game.

    I hope this information helps.

    Thank you

  • Why are the breakpoints and the page from the master page settings not inherited by all pages?

    Hello

    I've been busy creating a sensitive site with points to stop and a fluid width. Everything works now on my master page. But I found my breakpoints and the parameters of the page were not inherited from my master page for all other pages. To manually create all exactly the same breakpoints would be a lot of work. Can someone help me with the please my problem?

    Kind regards

    Tim

    When you apply a master page with breakpoints to another page, the breakpoints are displayed as markers of white triangle. All you need to do is add your breakpoints in the same place as markers.

    The reasoning behind this is likely that sometimes the content of the page should be changed more than the constant elements in the master.

    I hope this helps.

    David

    Creative muse

  • How to get the XML from the Request of Java object before sending. SOAP Web services

    I'm building Java request to Online Web Services and we'll call it application A . I got the WSDL forms the second part of the file in order to communicate with their application and we'll call it application B .

    Of the WSDL file generate the Java required classes that are Requests and Responses . classes Application A will send some request object after setting the parameters required and with the exception of response object of application B .

    The connection is established and the two applications A and B communicate with each other.

    Question:

    Of application A How can I get the xml data (or text file) for the request object before sending it to application B ?

    As described the connection is passing Java object such as request and I know that in some point this request will be converted to xml file. How to get it?

    -EDIT-

    Missing important information which can be confusing.

    I'm generated the Java rating were generated using the Axis framework

    The problem is solved by, add the following statements in the bindingStub class that was automatically generated from the WSDL file to the web-services you are trying to access.

       String request = _call.getMessageContext().getRequestMessage().getSOAPPartAsString(); 
     String response = _call.getMessageContext().getResponseMessage().getSOAPPartAsString();
    

    These statements should be placed after the following method call _call.invoke otherwise you will get NullPointerException .

    _callis a variable of type org.apache.axis.client.Cal and it is automatically generated byAxis

  • How to remove duplicates from the PL - SQL table?

    Hi gurus,

    I have a PL - SQL table with the following structure
    Authors (SR_NO, Auth_Code, Change_Date, cost)

    This table is filled using a slider. However, this table can have a few lines in double (for column (Auth_Code)
    for example
    SR_NO      Auth_Code       Change_Date                       Cost
    1               A1             14-FEB-09 08.18.47 AM          11.00
    2               A2             14-FEB-09 08.18.56 AM       2839.00
    3               A1             15-FEB-09 08.00.02 AM      1299.00
    4               A1             15-FEB-09 07.00.00 AM        789.00
    5               A3             14-FEB-09 08.18.56 AM        312.00
    6               A4             14-FEB-09 08.19.02 AM        233.00
    I need to get the above result set select the separate lines of Auth_Code including the Change_Date is maximum (and store in another PL - SQL table for treatment later or even the removal of this table will be also!)

    of the data A1 is duplicated and a maximum Change_Date above = 15 February 09 08.00.02 AM.
    Where my PL - SQL Table that results must have given below
    SR_NO      Auth_Code       Change_Date                       Cost
    2               A2             14-FEB-09 08.18.56 AM       2839.00
    3               A1             15-FEB-09 08.00.02 AM      1299.00
    5               A3             14-FEB-09 08.18.56 AM        312.00
    6               A4             14-FEB-09 08.19.02 AM        233.00
    I'm not very aware of the PL - SQL tables and there is no chance to change the existing cursor that fills the data in this table PL - SQL.
    I guess that I need to compare each record of PL - SQL table with others, but do not know how to do this.

    Could you please help?

    Hello

    Like this?:

    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    
    SQL>
    SQL> with data as(
      2  select 1 as SR_NO, 'A1' as Auth_Code, to_date('14-FEB-09 08.18.47', 'dd-mon-yy hh24:mi:ss') as change_date,    11.00 as cost from dual union all
      3  select 2 as SR_NO, 'A2' as Auth_Code, to_date('14-FEB-09 08.18.56', 'dd-mon-yy hh24:mi:ss') as change_date,  2839.00 as cost from dual union all
      4  select 3 as SR_NO, 'A1' as Auth_Code, to_date('15-FEB-09 08.00.02', 'dd-mon-yy hh24:mi:ss') as change_date,  1299.00 as cost from dual union all
      5  select 4 as SR_NO, 'A1' as Auth_Code, to_date('15-FEB-09 07.00.00', 'dd-mon-yy hh24:mi:ss') as change_date,   789.00 as cost from dual union all
      6  select 5 as SR_NO, 'A3' as Auth_Code, to_date('14-FEB-09 08.18.56', 'dd-mon-yy hh24:mi:ss') as change_date,   312.00 as cost from dual union all
      7  select 6 as SR_NO, 'A4' as Auth_Code, to_date('14-FEB-09 08.19.02', 'dd-mon-yy hh24:mi:ss') as change_date,   233.00 as cost from dual)
      8  select * from data d where change_date = (select max(change_date) from data d2 where d.auth_code = d2.auth_code);
    
         SR_NO AUTH_CODE CHANGE_DATE       COST
    ---------- --------- ----------- ----------
             2 A2        14/02/2009        2839
             3 A1        15/02/2009        1299
             5 A3        14/02/2009         312
             6 A4        14/02/2009         233
    
    SQL>
    

    Kind regards

  • How to parse the XML from the server BB10 Cascades development

    Hi all

    I'm new to BB10 development.

    I made the connection with my server that sends data to the XML Format. How to analyze.  Can someone help me with this.

    Also how to store data analysed in the Global Variable or ArrayList.

    Concerning

    Stephenson

    I thought you wanted to do stunts (qml).
    I use Qt

    QByteArray data = currentReply->readAll();
    xml.addData(data); //xml is a QXmlStreamReader
    

    to parse the xml, it is pretty simple if you look at the API.

    Here is a snippet of my code:

    while (!xml.atEnd()) {
        xml.readNext();
        /** start of an element **/
        if (xml.isStartElement()) {
            currentTag = xml.name().toString();
            if (xml.name() == "version") {
    

    the feed reader goes hierarchically, so you can simply call routines to analyze the different parts of the xml if the name() corresponds to a certain value.

  • Remove the cd from the master - need to recompose to hunt the config?

    New view.  Has established an office and noticed that they had two LUNS attached, she wondered why.  Looks like the other may be because the original master had an iso CD attached.

    Before removing all of the clones, what I have to change (disconnect the cd) of the master and then recompose?

    Thank you

    You can make the change on the master and recompose or you can the script just change on the clones as a stopgap until you press another image.

  • Problem with the pages created from the master

    I work on a leyouts of photo album and have created multiple master pages containing "Rectangle Frames". I want to use these images to insert pictures.

    If I insert the photos in frames on the master WITHOUT creating a new page, based on the mask, everything works fine.

    However if I create a new page and apply this master, I can add pictures to a few "Rectangle frames" properly but some do not accept the image at all or streach the picture outside its borders. In any case most of the frameworks become unusable (?)

    I tried to recreate some masters, but didn't help at all.

    No idea how to solve this problem is appreciated.

    Thank you.

    Guides can be selected and copied like any other object, as long as they are not locked. If you want them in the same position in a new page or a document, you can "paste in place."

  • How to get the diagram ER or master child tables details

    Hi team,

    I would like to get the details of the child Master Table Details (ER Diagram). I use the PLSQL developer.

    Could you please suggest how to get this tool or by using the query.

    Thank you

    Vincent

    Hi mohamed,.

    Please use TOAD. You ask to go to the link below: -.

    Toad Data Modeling - Diagram ER to create and generate the Script DDL/SQL - videos - Toad Data Modeling - Toad World

    Thank you

    Jihane Narain Sylca

Maybe you are looking for