How to insert into xml table from relational table

I wrote a sqlstaement that selects value from the relational tables. Now I want to replace root node "<event_start01>" with following value to the above selected xml string. My select returns root node and all nodes and elements of the root node.
I tried holding above sellected value into varchar2 variable but I get ora-00600 error. If I hold above selected values into xmltype variable then I am not able to replace root node with the following value.
I want to rplace rootnode with the following string.
INSERT INTO FRMD_EVENT_START01(xml_event_start) VALUES
(XMLTYPE('<event_start01
xmlns="event_start01.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="event_start01.xsd
event_start01.xsd">

Normally, you'd do this by joining B, C, and D together. In the simplest case, something like
INSERT INTO A( col1, ... col10 )
  SELECT B.col1, ..., B.col4,
         C.col5,
         D.col6, ..., D.col10
    FROM B,
         C,
         D,
   WHERE B.someKeyColumn = C.someKeyColumn
     AND C.anotherKeyColumn = D.anotherKeyColumnYou'd have to know how the data in B, C, and D relate to fill in the WHERE clause. This basically tells Oracle how to match the data in a particular row in B with the data in a particular row in C with the data in a particular row in D.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC

Similar Messages

  • How to create xml file from relational tables in 10gR2

    Hi,
    I am very new to XML and was wondering how to create an XML file from querying relational tables. Some child tables may contain multiple rows that need to be returned in certain instances. Other queries will just be single or multiple rows from one or more tables. I would like to use the latest feathers in 10gR2. Thanks for any help you can provide.
    Thanks,
    Lee

    Here is the first row of data created from our person table - it used the column names as the tag names:
    <?xml version="1.0"?>
    <ROWSET>
         <ROW>
              <MP_ID_SEQ>289</MP_ID_SEQ>
              <MP_NAME>LOBERG,JUDITH LEE</MP_NAME>
              <MP_SEX>F</MP_SEX>
              <MP_RACE>I</MP_RACE>
              <MP_DOB>19500709</MP_DOB>
              <MP_HT>504</MP_HT>
              <MP_WT>170</MP_WT>
              <MP_EYE_CLR>BLU</MP_EYE_CLR>
              <MP_HAIR_CLR>BRO</MP_HAIR_CLR>
              <MP_SKN>RUD</MP_SKN>
              <MP_SMT>POCKMARKS</MP_SMT>
              <MP_SOC>517607968</MP_SOC>
              <MP_OLN>517607968</MP_OLN>
              <MP_OLS>MT</MP_OLS>
              <MP_OLY>2007</MP_OLY>
              <MP_CAUT_MED>70</MP_CAUT_MED>
              <MP_VISION_SCRIPT>C0RRECTIVE LENSES</MP_VISION_SCRIPT>
              <MP_DNA_AVAIL>N</MP_DNA_AVAIL>
              <CREATED_BY>MMPS</CREATED_BY>
              <DTM_CREATED>31-AUG-06</DTM_CREATED>
              <MI_INC_ID_SEQ>288</MI_INC_ID_SEQ>
              <MP_ALERT>N</MP_ALERT>
         </ROW>

  • XML Data from Relational Tables

    Hi,
    My requirement is to pull data from relational tables into xml format and port it to the user (either as a file or allow the user to access it directly from their browser). What is the best way to accomplish this. Your suggestions are appreciated.
    thanks.

    Marco,
    Thanks for your reply, did try that , but I want the users to query this view also. Due to the nature of the xml structure I am getting the correct results. May be my xpath query is not right? My xml is as below:
    <node1 attribute-node1 = "somevalue1">
    <cnode1 attribute-cnode1 = "somevalue2">
    <cnode2 attribute-cnode2 = "somevalue3">
    <cnode3>somevalue4</cnode3>
    <cnode4>somevalue5</cnode4>
    </cnode2>
    <cnode2 attribute-cnode2 = "somevlaue6">
    <cnode3>somevalue6</cnode3>
    <cnode4>somevalue7</cnode4>
    </cnode2>
    </cnode1>
    </node1>
    and my requirement is like : the user wants to see only cnode2 with attribute value "somevalue3" (along with the rest of the xml) ie
    <node1 attribute-node1 = "somevalue1">
    <cnode1 attribute-cnode1 = "somevalue2">
    <cnode2 attribute-cnode2 = "somevalue3">
    <cnode3>somevalue4</cnode3>
    <cnode4>somevalue5</cnode4>
    </cnode2>
    </cnode1>
    </node1>
    Need the correct xpath query for this.
    Thanks

  • How to delete an .xml file from xmltype table?

    Hi expert,
    I am in I am in Oracle Enterprise Manager 11g 11.2.0.1.0.
    SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 22 11:40:23 2011
    I have inserted 3 .xml files into an xmltype table: DOCUMENT
    SQL> SELECT OBJECT_VALUE FROM document;
    OBJECT_VALUE
    <?xml version="1.0" encoding="WINDOWS-1252"?>
    <?xml-stylesheet href="http://www.accessdata.fda.gov/spl/stylesheet/spl.xsl" type="text/xsl"?>
    <document xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLoc
    ation="urn:hl7-org:v3 http://localhost:8080/home/DEV/xsd/spl.xsd" classCode="DOC">
    <id root="5ca4e3cb-7298-4948-8cc2-58e71ad32694"/>
    <code code="51725-0" c
    <?xml version="1.0" encoding="WINDOWS-1252"?>
    <?xml-stylesheet href="http://www.accessdata.fda.gov/spl/stylesheet/spl.xsl" type="text/xsl"?>
    <document xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLoc
    ation="urn:hl7-org:v3 http://localhost:8080/home/DEV/xsd/spl.xsd" classCode="DOC">
    <id root="03d6a2cd-fdda-4fe1-865d-da0db9212f34"/>
    <code code="51725-0" c
    <?xml version="1.0" encoding="WINDOWS-1252"?>
    <?xml-stylesheet href="http://www.accessdata.fda.gov/spl/stylesheet/spl.xsl" type="text/xsl"?>
    <document xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLoc
    ation="urn:hl7-org:v3 http://localhost:8080/home/DEV/xsd/spl.xsd" classCode="DOC">
    <id root="09ff06d6-8b85-43dd-b5cc-e22d00f02bd0"/>
    <code code="51725-0" c
    I tried to delete one xml file which with id root="03d6a2cd-fdda-4fe1-865d-da0db9212f34'
    delete from DOCUMENT
    where xmlexists('$p/document/id[@root="03d6a2cd-fdda-4fe1-865d-da0db9212f34"]'PASSING OBJECT_VALUE AS "p");
    but failed.
    Is there any expert can help?
    Thanks a lot!
    Cow
    Edited by: Cow on Mar 11, 2011 7:02 PM

    Hi,
    Namespace issue.
    You have to declare it in the XQuery prolog :
    DELETE FROM document
    WHERE XMLExists( 'declare default element namespace "urn:hl7-org:v3"; (::)
                      $p/document/id[@root=$root_value]'
                     passing object_value as "p",
                             '03d6a2cd-fdda-4fe1-865d-da0db9212f34' as "root_value" )
    ;

  • Create a large XML extract from relational tables - 10g

    The Oracle 10g documentation recommends using the various SQL functions such as XMLAGG,XMLELEMENT or DBMS_XMLGEN under chapter "16 Generating XML Data from the Database" for generating a XML extract file. The DBMS_XMLDOM seems like a useful structured package to create a XML formatted extract. Any idea why Oracle does not recommend the use of XMLDOM API ? Are there performance issues or likely de-support ?
    Whats the best way to produce a large XML extract?
    Thanks.

    mdrake wrote:
    No reason not to use it. It just tends to require a lot more coding than the other methods. Underneath the covers they all map into the same code-line. In general, to generate a given XML document you wlll write far fewer lines of code using the SQL/XML operators. Less Code written = less code to maintan = faster time to market.Less code to parse...?

  • How to insert into a table from 3 tables?

    Hello,
    How to insert into a table getting values from 3 different tables?
    For example table_A has col_1 to col_10.
    I want to insert into table_A,
    values: col_1 to col_4 are from table_B,
    col_5 is from table_C,
    col_6 to col_10 are from table_D.
    Thanks!

    Normally, you'd do this by joining B, C, and D together. In the simplest case, something like
    INSERT INTO A( col1, ... col10 )
      SELECT B.col1, ..., B.col4,
             C.col5,
             D.col6, ..., D.col10
        FROM B,
             C,
             D,
       WHERE B.someKeyColumn = C.someKeyColumn
         AND C.anotherKeyColumn = D.anotherKeyColumnYou'd have to know how the data in B, C, and D relate to fill in the WHERE clause. This basically tells Oracle how to match the data in a particular row in B with the data in a particular row in C with the data in a particular row in D.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to insert large xml data into database tables.

    Hi all,
    iam new to xml. i want to insert data in xml file to my database tables.but the xml file size is very large. performance is also one of the issue. can anybody please tell me the procedure to take xml file from the server and insert into my database tables.
    Thanks in advance

    Unfortunately posting very generic questions like this in the forum tends not to be very productive for you, me or the other people who read the forum. It really helps everyone if you take a little time to review existing posts and their answers before starting new threads which replicate subjects that have already been discussed extensively in previous threads. This allows you to ask more sensible questions (eg, I'm using this approach and encountering this problem) rather than extremely generic questions that you can answer yourself by spending a little time reviewing existings posts or using the forum's search feature.
    Also in future your might want to try being a little more specific before posting questions
    Eg Define "very large". I know of customers who thing very large is 100K, and customers who think 4G is medium. I cannot tell from your post what size your files are.
    What is the content of the file. Is it going to be loaded into a single record, or a a single table, or will it need to be loaded into multiple records in a single table or multiple records in multiple tables ?
    Do you really need to load the data into exsiting relational tables or could your application work with relational views of the XML Content.
    Finally which release of the database are you working with.
    Define performance. Is it reasonable to expect to process this kind of document on this machine (Make, memory, #number of CPUs, CPU Speed, number of discs) in this period of time.
    WRT to your original question. If you take a few minutes to search this forum you will find a very large number of threads with very similar titles to yours. These theads document a number of different approaches that can be used to solve this problem.
    I suggest you start by looking for threads that cover topics like DBMS_XMLSTORE, XMLTable(), Relational Views of XML content, loading XML content in relational tables.

  • How to insert into a table in database1 from a table in database2?

    hi!
    how to insert into a table in database1 from a table in
    database2?
    can anyone help?
    Tariq.

    using the EXEC_SQL package.
    see form help for detail.
    Regards.

  • How to insert External XML file content into XMLTYPE through Pro*c

    Could any one sugest me how to insert a external XML file content into Db
    into XMLTYPE datatype through Pro*c program.
    Thanks for any help...... who has done this
    Ghanta Tagore

    Hi
    After some good fight of 3 days, I have done it through Pro*c
    This is the way to handle this
    Buffer-->Temporary Clob-->XMLTYPE(using CreateXml)
    Pasting my piece o code to do this
    ===============
    OCIClobLocator *license_txt;
    varchar h_ttt[1024] = {'\0'};
    ub4 amt;
    int i;
    EXEC SQL ALLOCATE :license_txt;
    EXEC SQL LOB CREATE TEMPORARY :license_txt ;
    GetName(name); /*Gets Name to insert into name column in License Table*/
    for(i=0; i<4;i++)
    GetXMLL((char *)h_ttt.arr); /*Gets a string value of XML into this example*/
    /*<Tagore>Is From TCS Delhi</Tagore>*/
    /*This can be changed to get buffer from FILE */
    h_ttt.len = strlen((char *)h_ttt.arr);
    amt = sizeof(char) * h_ttt.len ;
    EXEC SQL LOB WRITE APPEND :amt FROM :h_ttt INTO :license_txt;
    EXEC SQL
    INSERT INTO license_table VALUES (:sss, :name, sys.xmltype.createXML(:license_txt))
    ================
    Thanks For ur Help
    Tagore Ghanta

  • How to insert into a table with a nested table which refer to another table

    Hello everybody,
    As the title of this thread might not be very understandable, I'm going to explain it :
    In a context of a library, I have an object table about Book, and an object table about Subscriber.
    In the table Subscriber, I have a nested table modeling the Loan made by the subscriber.
    And finally, this nested table refers to the Book table.
    Here the code concerning the creation of theses tables :
    Book :
    create or replace type TBook as object
    number int,
    title varchar2(50)
    Loan :
    create or replace type TLoan as object
    book ref TBook,
    loaning_date date
    create or replace type NTLoan as table of TLoan;
    Subscriber :
    create or replace type TSubscriber as object
    sub_id int,
    name varchar2(25)
    loans NTLoan
    Now, my problem is how to insert into a table of TSubscriber... I tried this query, without any success...
    insert into OSubscriber values
    *(1, 'LEVEQUE', NTLoan(*
    select TLoan(ref(b), '10/03/85') from OBook b where b.number = 1)
    Of course, there is an occurrence of book in the table OBook with the number attribute 1.
    Oracle returned me this error :
    SQL error : ORA-00936: missing expression
    00936. 00000 - "missing expression"
    Thank you for your help

    1) NUMBER is a reserved word - you can't use it as identifier:
    SQL> create or replace type TBook as object
      2  (
      3  number int,
      4  title varchar2(50)
      5  );
      6  /
    Warning: Type created with compilation errors.
    SQL> show err
    Errors for TYPE TBOOK:
    LINE/COL ERROR
    0/0      PL/SQL: Compilation unit analysis terminated
    3/1      PLS-00330: invalid use of type name or subtype name2) Subquery must be enclosed in parenthesis:
    SQL> create table OSubscriber of TSubscriber
      2  nested table loans store as loans
      3  /
    Table created.
    SQL> create table OBook of TBook
      2  /
    Table created.
    SQL> insert
      2    into OBook
      3    values(
      4           1,
      5           'No Title'
      6          )
      7  /
    1 row created.
    SQL> commit
      2  /
    Commit complete.
    SQL> insert into OSubscriber
      2    values(
      3           1,
      4           'LEVEQUE',
      5           NTLoan(
      6                  (select TLoan(ref(b),DATE '1985-10-03') from OBook b where b.num = 1)
      7                 )
      8          )
      9  /
    1 row created.
    SQL> select  *
      2    from  OSubscriber
      3  /
        SUB_ID NAME
    LOANS(BOOK, LOANING_DATE)
             1 LEVEQUE
    NTLOAN(TLOAN(000022020863025C8D48614D708DB5CD98524013DC88599E34C3D34E9B9DBA1418E49F1EB2, '03-OCT-85'))
    SQL> SY.

  • SQL Loader-How to insert -ve & date values from flat text file into coloumn

    Question: How to insert -ve & date values from flat text file into coloumns in a table.
    Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
    How to load such values in columns of database using SQL Loader?
    Please guide.

    Question: How to insert -ve & date values from flat text file into coloumns in a table.
    Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
    How to load such values in columns of database using SQL Loader?
    Please guide. Try something like
    someDate    DATE 'DDMMYYYY'
    someNumber1      "TO_NUMBER ('s99999999.00')"
    someNumber2      "TO_NUMBER ('99999999.00s')"Good luck,
    Eric Kamradt

  • Create Big XML files ( extract ) from Relational Tables

    Experts: I need to create a big XML extract more than 5Gb , from relations tables using SQLX. I read the excellent FAQ given by MDrake in the following thread.
    https://forums.oracle.com/thread/418001
    Question
    1) Is it better to use XML schema, My XML output format is pretty much going to be static, so I can register an XML schema .
    2) Does Registering the XMLschema help with better memory management. I recall I used to get out of memory exception when I generated xml documents on oracle 10g using DBMS_XMLGEN.
    3) Can I generate this 5 Gb of XML file using oracle's default DOM parser?
    Thanks
    Kevin

    Hi Kevin,
    1) Is it better to use XML schema, My XML output format is pretty much going to be static, so I can register an XML schema .
    2) Does Registering the XMLschema help with better memory management. I recall I used to get out of memory exception when I generated xml documents on oracle 10g using DBMS_XMLGEN.
    No, an XML schema won't help for the generation.
    It is useful though if you're looking for the opposite task, i.e. loading an XML file into database tables.
    3) Can I generate this 5 Gb of XML file using oracle's default DOM parser?
    What is the default DOM parser ? Do you mean DBMS_XMLDOM APIs?
    Since you want to generate XML, there's not much to parse.
    Generally, using SQL/XML functions is the way to go.
    You may still hit some performance/memory issues while reaching such a size, especially with large XMLAgg aggregation context.
    If you do, you may switch to chunk generation instead. I've got some pretty good result with this approach and the parallel query feature.

  • Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the rows? Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.

    Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the records?
    Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.

    The Oracle documentation has a good overview of the options available
    Generating XML Data from the Database
    Without knowing your version, I just picked 11.2, so you made need to look for that chapter in the documentation for your version to find applicable information.
    You can also find some information in XML DB FAQ

  • How to insert into more than one table at a time also..

    hi,
    i am a newbee.
    how to insert into more than one table at a time
    also
    how to get a autoincremented value of an id say transactionid for a particular accountid.
    pls assume table as
    transactionid accountid
    101 50
    102 30
    103 50
    104 35
    i want 102 for accountid 30 and 103 for accountid 50.
    thank u

    @blushadow,
    You can only insert into one table at a time. Take a look here :
    Re: insert into 2 tables
    @Raja,
    I want how to extract the last incremented value not to insert.Also, I don't understand your thread title... which was "how to insert into more than one table at a time also.. "
    Insert, extract... ? Can you clarify your job ?
    Nicolas.

  • Insertion into local table from remote table with contains clause

    Hi all,
    We are tasked to insert some rows into our database from another database. We tried to use DBLinks to link the 2 databases and were able to use Select statements to filter out the data that we need to insert into our database.
    These statements take the form of: Select * from RemoteTable where contains@RemoteLink(IndexColumn, 'car')>0;
    where RemoteLink is the DBLink that we have created.
    However Oracle gave us an error (ORA-00949: illegal reference to remote table) when we tried to insert the dataset from the above statement into our local table. We used the following statement in doing so: Insert Into LocalTable (Select * from RemoteTable where contains@RemoteLink(IndexColumn, 'car')>0);
    Even if we use Create Table, Oracle gave us the same error when we tried to push the data from the Select Statement into the new table.
    Could anyone advise us whether it is possible to insert such data into a local table? And if som what is the proper way of doing it?
    Many thanks to any advises.

    Hi,
    there is document 261741.1 on Metalink. This states explicitly that it is not possible to invoke remote user-defined operators, and contains is such. The solution given in the article is to create a wrapper function on the remote site and this one calling in stead of contains.
    Herald ten Dam
    htendam.wordpress.com

Maybe you are looking for

  • Creating a Link on the Column Heading

    Good afternoon, I know with reports, you can create a link for each cell in the report attributes section. My question is it there's any way to create a link for the column header without hard coding it into the query that generating the results. Tha

  • Photoshop saves images darker than they appear in-program

    I am using Photoshop CS6 64-bit version, and I also had this problem with the previous Photoshop CS5 (64-bit aswell). (Windows 7 64-bit) I've had this problem for a very long time and I've been looking for answers for tons of times however this time

  • Converting profiles

    I've received some TIF files created in basic sRGB mode but that contain Adobe 1998 images within them. The files, I've been told, were saved without embedding any profile to them. My printer just told me that I need to have a matching color profile,

  • Export Masters to include star ratings, places, faces, and tags?

    I have 25,000 photos at about 2.5 mb each that I have imported into Aperture. The original import file was about 60gb. The current Aperture file is about 205gb. If I export masters, I get a file that is 60gb (same aas the orignal import file. If I ex

  • Just bought PSE 12 and it won't install help?

    Just bought PSE 12 and it will not install on my Windows 7 computer.  I keep getting errors.  Been on hold for 36 minutes with Adobe chat and still waiting to talk to someone.  Any help would be greatly appreciated!