How to insert one table data into multiple tables by using procedure?

How to insert one table data into multiple tables by using procedure?

Below is the simple procedure. Try the below
CREATE OR REPLACE PROCEDURE test_proc
AS
BEGIN
INSERT ALL
  INTO emp_test1
  INTO emp_test2
  SELECT * FROM emp;
END;
If you want more examples you can refer below link
multi-table inserts in oracle 9i
Message was edited by: 000000

Similar Messages

  • 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 wifi scan data into sql table

    Urgent assist required. Can someone help pls, i have scanned wifi data in C# that i have split into required format MAC,SSID and RSSi . I want when i push a button the results are inserted into an sql table that i already created. and if i push the buton
    again it stops inserting. I have tried several methods and could not get it to work, Will appreciate assist
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Data.SqlClient;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.IO.Ports;
    namespace WICED_SERIALPORT_TEST
        public partial class Form1 : Form
            public Form1()
                InitializeComponent();
            private void button1_Click(object sender, EventArgs e)
                string[] ports = SerialPort.GetPortNames();
                foreach (string port in ports)
                    comboBox1.Items.Add(port);
            string t;
            private void button2_Click(object sender, EventArgs e)
                t = comboBox1.Text.ToString();
                sErial(t);
            SerialPort sp;
            void sErial(string Port_name)
                sp = new SerialPort(Port_name, 115200, Parity.None, 8, StopBits.One);
                sp.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);
                sp.Open();
            private void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
                SerialPort sp = (SerialPort)sender;
                string msg = string.Empty;
                bool canCont = false;
                while (!canCont)
                    msg += sp.ReadLine();
                    if (msg.Contains("Scan complete "))
                        canCont = true;
                //string w = sp.ReadLine();
                //string w = sp.ReadExisting();
                // string msg = sp.ReadExisting();
                string[] msgArr = msg.Split('\r');
                Invoke(new Action(() => listBox1.Items.Clear()));
                List<string[]> list = new List<string[]>();
                List<Networks> Scan = new List<Networks>();
                for (int i = 0; i < msgArr.Length; i++)
                    list.Add(msgArr[i].Split(new string[] { "  " }, StringSplitOptions.RemoveEmptyEntries));
                for (int i = 0; i < list.Count; i++)
                    if (i > 2)
                        if (list[i].Length > 4)
                            int numOfSplits = 0;
                            List<string> tempList = new List<string>();
                            for (int ii = 0; ii < list[i].Length; ii++)
                                if (numOfSplits < 6)
                                    string[] temp1 = list[i][ii].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                                    numOfSplits += temp1.Length;
                                    for (int iii = 0; iii < temp1.Length; iii++)
                                        tempList.Add(temp1[iii]);
                                else
                                    tempList.Add(list[i][ii]);
                            Scan.Add(new Networks()
                                ID = Convert.ToInt32(tempList[0]),
                                NetworkType = tempList[1],
                                MAC = tempList[2],
                                RSSi = Convert.ToInt32(tempList[3]),
                                Rate = Convert.ToDouble(tempList[4]),
                                Channel = Convert.ToInt32(tempList[5]),
                                Security = tempList[6],
                                SSID = tempList[7],
                if (msg != String.Empty)
                    Invoke(new Action(() => richTextBox1.AppendText(msg)));
                for (int i = 0; i < Scan.Count; i++)
                    Invoke(new Action(() => listBox1.Items.Add(Scan[i].MAC)));
                    Invoke(new Action(() => listBox2.Items.Add(Scan[i].RSSi)));
                    Invoke(new Action(() => listBox3.Items.Add(Scan[i].SSID)));
                    msg = string.Empty;
                    list.Clear();
            private void richTextBox1_TextChanged(object sender, EventArgs e)
            private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
            private void richTextBox2_TextChanged(object sender, EventArgs e)
            private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
            private void Form1_Load(object sender, EventArgs e)
            public SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\AP_SCAN_DATA.mdf;Integrated Security=True");
            private void button3_Click(object sender, EventArgs e)
                using (SqlConnection connection = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\AP_SCAN_DATA.mdf;Integrated Security=True"))
        using (SqlCommand command = new SqlCommand())
            command.Connection = connection;            // <== lacking
            command.CommandType = CommandType.Text;
            command.CommandText = "INSERT into LOCATIONSCAN ((Scan[i].SSID),(Scan[i].MAC), (Scan[i].RSSi)) VALUES (@SSID, @MAC, @RSSi)";
            command.Parameters.AddWithValue("@SSID", listBox1);
            command.Parameters.AddWithValue("@MAC", listBox2);
            command.Parameters.AddWithValue("@RSSi",listBox3);
            try
                connection.Open();
                int recordsAffected = command.ExecuteNonQuery();
            catch(SqlException)
                // error here
            finally
                connection.Close();

    Hello,
    Remove the Try-Catch as this hides any errors that may be raised. It is unwise to use a Try-Catch this way, always when using a Try-Catch write code that alerts or writes to a log file. Also, there is no need for invoke Close method for the connection object,
    the Using statement closes the connection for you.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

  • Inserting data into multiple tables in jdbc

    I am doing on file to jdbc. Now I got a requirement to insert data into multiple tables on the receiver side. How can I do this ?

    Hi,
    you are going to insert data into 4 tables in a sequence one after another , I see three options.
    1) Stored procedure and 2) creating 4 statement data structure (one for each table)
    The third option is writing a SQL with join for the 4 tables and use action command = SQL_DML. Example as follows....
    Write SQL code and place it in access tag. Pass values for the columns using key tag...
    <stmt>
        <Customers action="SQL_DML">
          <access> UPDATE Customers SET CompanyName=u2019$NAME$u2019, Address=u2019$ADDRESS$' WHERE CustomerID='$KEYFIELD$u2019
          </access>
          <key>
            <NAME>name</NAME>
            <ADDRESS>add </ADDRESS>
            <KEYFIELD>1</KEYFIELD>
          </key>
        </Customers>
      </stmt>
    Refer this http://help.sap.com/saphelp_nwpi71/helpdata/en/44/7b7855fde93673e10000000a114a6b/content.htm
    Hope this helps ....

  • Insert data into multiple tables

    Hi all,
    I've a requirement where i need to insert data into multiple tables using PL/SQL procedure
    Procedure should have two parameters
    1. Table Name (parameter1)
    2. Data (parameter2)
    Based on these two parameters i need to insert data into table (parameter1) using data (parameter2)
    ex:
    Procedure insert_data (p_table  IN VARCHAR2
                          ,p_data   IN -- what should be the datatype?
    IS
    l_statement VARCHAR2(2000);
    BEGIN
    -- insert data into tables
    INSERT INTO p_table
    values (....);
    END insert_data;Thanks in advance!!

    BEDE wrote:
    Amen to that!
    So, I believe a better approach would be the following...
    Suppose you have N datafiles with the same structure, and you wish to insert into the database the data from all those files.
    For that, you should have a single table, named, say incoming_file_data, which should be structured more or less like below:
    create table incoming_file_data (
    filename varchar2(250) not null -- name of the file inserted from
    ,file_time timestamp -- timestamp when the data was inserted
    ,... -- the columns of meaningful data contained in the lines of those files
    );And you will insert the data from all those files in this table, having normally one transaction for each file processed, for otherwise, when shit happens, some file may only get to be partially inserted into the table...
    Maybe one good approach would be to create dynamically an external table for the file to be loaded, and then execute dynamically insert select into the table I said, so that you will have only one insert select for one file instead of using utl_file... RTM on that.If the file structures are the same, and it's just the filename that's changing, I would have a single external table definition, and use the alter table ... location ... statement (through execute immediate) to change the filename(s) as appropriate before querying the data. Of course that's not scalable if there are multiple users intenting to use this, but generally when we talk about importing multiple files, it's a one-user/one-off/once-a-day type of scenario, so multi-user isn't a consideration.

  • How to insert a table data into temporary table

    Hi
    Can anyone help me to insert a table data into temporary table.
    Thanks
    Navin

    If you could provide a (simplified) example of the data you have and the output you're attempting to get, that would probably be quite helpful. I'm not sure that I understand exactly what you're trying to do here...
    1) It sounds like you know the structure of the result set you're trying to generate. So it would be possible to create a temporary table once (at the same time that you create all your other tables) and write procedural PL/SQL code that would step through the data, write data to the temp table, select the data out of the temp table, and return a REF CURSOR. That would tend not to be the way that an Oracle developer would do things (there are exceptions, of course), but it would work.
    2) I don't see any inherent problems in using sub-selects and inline views to do whatever aggregation you're trying to do on the secondary tables, which would allow you to get the output in a single query. For example, given an ORDERS table and an ORDER_DETAILS table,
    SELECT o.customer_id, o.invoice_number, SUM( od.line_item_cost ) total_cost
      FROM orders o,
           order_details od
    WHERE o.order_id = od.order_id
    GROUP BY o.customer_id, o.invoice_number3) If you do need to use procedural logic, I would tend to look into the use of pipelined table functions or to read the data into an in-memory collection and to manipulate and return that collection.
    Justin

  • How to load Matrix report data into basic table data using ODI

    Hi,
    How to load Matrix report data into basic table data using oracle Data Integrator ?
    Requirement Description:
    Following is the matrix report data:
    JOB                       DEPT10                DEPT20 
    ANALYST                                           6000
    CLERK                   1300                     1900 Need to convert it into below format:
    JOB                             Dept                        Salary
    ANALYST                  DEPT10     
    ANALYST                  DEPT20                     6000
    CLERK                       DEPT10                    1300
    CLERK                       DEPT20                    1900
        Thanks for your help in advance. Let me know if any further explanation is required.

    Your list seems to be a little restrictive, you can do a lot more with ODI procedures.
    If you create new procedure, and add a step. In the 'command on source' tab set you technology and schema as per your source database. Use the unpivot functionality as described in the link, please, rather than using 'SELECT *' use the appropriate column names and alias them for eg:
    SELECT job as job,
    deptsal as deptsal,
    saldesc as saledesc
    FROM pivoted_data
    UNPIVOT (
    deptsal --<-- unpivot_clause
    FOR saldesc --<-- unpivot_for_clause
    IN (d10_sal, d20_sal, d30_sal, d40_sal) --<-- unpivot_in_clause
    Then in your 'command on target' tab set the technology and schema to your target db, then put your INSERT statement for eg:
    INSERT INTO job_sales
    (job,
    deptsal,
    saledesc
    VALUES
    :job,
    :deptsal,
    :saledesc
    Therefore you are using bind variables from source to load data into target.
    Obviously if the source and target table are in the same database, then you can have it all in one statement in the 'command on target' as
    INSERT INTO job_sales
    (job,
    deptsal,
    saledesc
    SELECT job as job,
    deptsal as deptsal,
    saldesc as saledesc
    FROM pivoted_data
    UNPIVOT (
    deptsal --<-- unpivot_clause
    FOR saldesc --<-- unpivot_for_clause
    IN (d10_sal, d20_sal, d30_sal, d40_sal) --<-- unpivot_in_clause
    also set the log counter as 'Insert' on the tab where your INSERT statement is, so you know how many rows you insert into the table.
    Hope this helps.
    BUT remember that this feature only came out in Oracle 11g.

  • How to insert a gif file into a table?

    Hi,
    I need to insert a gif file into a table. Can anyone tell me where I can find the information on how to create this kind of table, how to insert a gif file into a table and how to select?
    Thanks,
    Helen

    Hi Helen,
    You could read about that in the documentation which is available online.
    For a starter: BLOB. And I bet there are many examples to be found on the web.
    Good luck. :)
    Regards,
    Guido

  • INSERTION OF XML DATA INTO THE TABLE USING XMLDOM

    hello,
    i am using XMLDOM to insert the data into the table
    i am using different function of it.
    but i am facing the problem to retrive the the multiple entry.
    like in my example i have two entry of the ' po number '
    & i am using the function
    dbms_xmldom.item(l_nodelist, 0)
    i which i have to pass index no.
    & through this i am getting only single entry according to the index no.
    Example on which i am working is
    declare
    l_xml_data CLOB;
    l_xml_doc dbms_xmldom.domdocument;
    l_nodelist dbms_xmldom.DOMNodeList;
    l_node dbms_xmldom.domnode;
    l_xmltype XMLTYPE;
    l_po_num VARCHAR2(30);
    l_cust_ord VARCHAR2(30);
    l_item_code VARCHAR2(30);
    begin
    l_xml_data := '<?xml version="1.0" encoding="UTF-8"?>
    <!--DOCTYPE MobileInventoryResponse SYSTEM "MobileInventoryResponse.dtd"-->
    <MobileInventoryResponse>
         <message>
              <message-header>
                   <message-id>16244182</message-id>
                   <transaction-name>ship-advice</transaction-name>
                   <partner-name>cbeyond</partner-name>
                   <source-url>http://www.brightpoint.com</source-url>
                   <create-timestamp>20080826150709</create-timestamp>
                   <response-request>1</response-request>
              </message-header>
              <ship-advice>
                   <header>
                        <customer-id>297859</customer-id>
                        <shipment-information>
                             <ship-first-name>RA_13Aug_1</ship-first-name>
                             <ship-last-name>MIND</ship-last-name>
                             <ship-address1>test</ship-address1>
                             <ship-city>test</ship-city>
                             <ship-state>VA</ship-state>
                             <ship-post-code>22102-4931</ship-post-code>
                             <ship-country-code>US</ship-country-code>
    <ship-phone1>0040726335068</ship-phone1>
    <ship-email>[email protected]</ship-email>
    <ship-via>FX01</ship-via>
    <ship-request-date>20080826</ship-request-date>
    <ship-request-warehouse>CBY1</ship-request-warehouse>
    </shipment-information>
    <purchase-order-information>
    <purchase-order-number>380928</purchase-order-number>
    <purchase-order-number>380929</purchase-order-number> ----modi by Ananda Dubey
    <account-description/>
    <purchase-order-amount>0.0</purchase-order-amount>
    <currency-code>USD</currency-code>
    </purchase-order-information>
    <order-header>
    <customer-order-number>0002759</customer-order-number>
    <customer-order-date>20080826</customer-order-date>
    <order-sub-total>19.0</order-sub-total>
    <order-discount>0.0</order-discount>
    <order-tax1>0.0</order-tax1>
    <order-tax2>0.0</order-tax2>
    <order-tax3>0.0</order-tax3>
    <order-shipment-charge>18.0</order-shipment-charge>
    <order-total-net>0.0</order-total-net>
    <order-status>Completed</order-status>
    <order-type/>
    <brightpoint-order-number>35028788</brightpoint-order-number>
    <warehouse-id>CBY1</warehouse-id>
    <ship-date>20080826</ship-date>
    </order-header>
    </header>
    <detail>
    <line-item>
    <line-no>1</line-no>
    <item-code>SKU1</item-code>
    <universal-product-code>0</universal-product-code>
    <ship-quantity>1.0</ship-quantity>
    <unit-of-measure>EA</unit-of-measure>
    <serial-list>
    <serial-numbers>
    <esn>TIMI000013</esn>
    </serial-numbers>
    </serial-list>
    <line-status/>
    <base-price>0.0</base-price>
    <line-discount>0.0</line-discount>
    <line-tax1>0.0</line-tax1>
    <line-tax2>0.0</line-tax2>
    <line-tax3>0.0</line-tax3>
    <bill-of-lading>929406733828</bill-of-lading>
    <scac>FX01</scac>
    </line-item>
    </detail>
    </ship-advice>
    <transactionInfo>
                   <eventID>16244182</eventID>
              </transactionInfo>
         </message>
    </MobileInventoryResponse>';
    l_xml_doc := dbms_xmldom.newDomDocument(l_xml_data);
    -- Method 1 to get data
    l_nodelist := dbms_xmldom.getelementsbytagname(l_xml_doc, 'purchase-order-number');
    l_node := dbms_xmldom.item(l_nodelist, 0); -- gets first item from list
    l_po_num := dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(l_node));
    dbms_output.put_line(l_po_num);
    l_nodelist := dbms_xslprocessor.selectnodes(dbms_xmldom.makenode(l_xml_doc),
    '/MobileInventoryResponse/message/ship-advice/detail/line-item/item-code');
    l_node := dbms_xmldom.item(l_nodelist, 0); -- gets first item from list
    l_item_code := dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(l_node));
    dbms_output.put_line(l_item_code);
    l_xmltype := XMLTYPE(l_xml_data);
    l_cust_ord := l_xmltype.extract('/MobileInventoryResponse/message/ship-advice/header/order-header/customer-order-number/text()').getStringVal();
    dbms_output.put_line(l_cust_ord);
    dbms_xmldom.freeDocument(l_xml_doc);
    end;
    /

    In the following code
    l_nodelist := dbms_xmldom.getelementsbytagname(l_xml_doc, 'purchase-order-number');
    l_node := dbms_xmldom.item(l_nodelist, 0); -- gets first item from listYou need to understand what the second parm on the .item call does. See [dbms_xmldom.item|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_xmldom.htm#i1126138]
    The nodelist is a 0 based array of information and you are only requesting to pull the node info in the first array position. So to get the info in the second array position, you need to use ", 1)". You can also use .getLength and a loop to parse through everything in the node list.

  • How to fetch single row data into multiple columns

    Hi Have a cursor
    which will have SELECT Sun_hrs,Mon_hrs,Tue_hrs,Wed_hrs,Thu_hrs,Fri_hrs,Sat_hrs from OTMaster;
    now my cursor has one row of the above columns with this row data I want to insert into other tale as column wise
    ex:
    my row is like this: Sun_hrs,Mon_hrs,Tue_hrs,Wed_hrs,Thu_hrs,Fri_hrs,Sat_hrs
    01:00 01:00 01:00 01:00 01:00 01:00 01:00
    now I want to insert the above data into table with loop along with weekday
    weekday, OTHrs
    1 01:00
    2 01:00
    3 01:00
    4 01:00
    5 01:00
    6 01:00
    7 01:00
    which type of variable I need to fetch the records, rowtype or tabletype,
    plz help me

    thank you for information, and now I am using UNPIVOT below is my query
    SELECT * FROM OTCEILINGMASTER
    UNPIVOT(OTHOURS FOR WEEK_DAY IN (SUN_CEILING_HRS AS '1',MON_CEILING_HRS AS '2',TUE_CEILING_HRS AS '3',
    WED_CEILING_HRS AS '4',THU_CEILING_HRS AS '5',FRI_CEILING_HRS AS '6',SAT_CEILING_HRS AS '7'));
    when I am selecting all the columns (select * from OTCEILINGMASTER) then only the above query is executing I want only two columns from the table however my table has 10 columns.
    please looking into this

  • Loading data into multiple tables using sqlloader

    Hi,
    I am using sql loader to load the data from flat file into the data base
    my file structure is as below
    ====================
    101,john,mobile@@fax@@home@@office@@email,1234@@3425@@1232@@2345@@[email protected],1234.40
    102,smith,mobile@@fax@@home,1234@@345@@234,123.40
    103,adams,fax@@mobile@@office@@others,1234@@1233@@1234@@3456,2345.40
    in file first columns are empno,ename,comm_mode(multiple values terminated by '@@'),comm_no_txt(multiple values terminated by '@@'), sal
    the comm_mode and comm_no_text needs to be inserted into the separate table (emp_comm) like below
    emp
    empno ename sal
    101 john 1234.40
    102 smith 123.40
    103 adams 2345.40
    emp_comm
    empno comm_mode comm_no_text
    101 mobile 1234
    101 fax 3425
    101 home 1232
    101 office 2345
    101 email [email protected]
    102 mobile 1234
    102 fax 345
    102 home 234
    103 fax 1234
    like this needs to insert the data using sql loader
    my table structures
    ===============
    emp
    empno number(5)
    ename varchar2(15)
    sal number(10,2)
    emp_comm
    empno number(5) reference the empno of the emp table
    comm_mode varchar2(10)
    Comm_no_text varchar2(35)
    now i want insert the file data into the specified structues
    please help me out to achieve this using sql loader
    (we are not using external tables for this)
    Thanks & Regards.
    Bala Sake
    Edited by: 954925 on Aug 25, 2012 12:24 AM

    Pl post OS and database details
    You will need to split up the datafile in order to load into separate tables. The process is documented
    http://docs.oracle.com/cd/E11882_01/server.112/e22490/ldr_control_file.htm#autoId72
    HTH
    Srini

  • Inserting data into multiple tables(Oracle Version 9.2.0.6)

    Hi,
    we are going to receive the following XML file from one of our vendor. We need to parse the file and then save the data to multiple database tables (around 3).
    <?xml version="1.0"?>
    <datafeed xmlns:xsi="ht tp://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="DailyFeed.xsd" deliverydate="2007-02-14T00:00:00" vendorid="4">
    <items count="1">
    <item feed_id="001379" mode="MERGE">
    <content empbased="true">
    <emp>10000000</emp>
    <value>
    </value>
    <date>2006-01-16</date>
    <unit>CHF</unit>
    <links>
    <link lang="EN">
    <url>www.pqr.com</url>
    <description>pqr website</description>
    </link>
    <link lang="DE">
    <url>www.efg.com</url>
    <description>efg website</description>
    </link>
    </links>
    </content>
    <content empbased="true">
    <emp>10000001</emp>
    <value>
    </value>
    <date>2006-01-16</date>
    <unit>CHF</unit>
    <links>
    <link lang="EN">
    <url>www.abc.com</url>
    <description>abc website</description>
    </link>
    <link lang="DE">
    <url>www.xyz.com</url>
    <description>xyz website</description>
    </link>
    </links>
    </content>
    <content empbased="true">
    <emp>10000002</emp>
    <value>
    </value>
    <date>2006-01-16</date>
    <unit>CHF</unit>
    <links>
    <link lang="IT">
    <url>www.rst.com</url>
    <description>rst website</description>
    </link>
    </links>
    </content>
    </item>
    </items>
    </datafeed>
    Now the operation to be done on the table depends on the mode attribute. Further, there are some basic validations need to be done using count attribute. Here the item tag, content tag & link tag are recurring elements.
    The problem is I am not able to find the correct attributes like mode, feed_id, lang through SQL query(they are getting duplicated) though I was able to find the deliverydate & vendorid attribute as they are non-repeatitive. Here are the scripts :
    create table tbl_xml_rawdata (xml_content xmltype);
    create directory xmldir as 'c:\xml';
    --put the above xml file in this directory and name it testfile.xml
    Declare
    l_bfile BFILE;
    l_clob CLOB;
    BEGIN
    l_bfile := BFileName('XMLDIR', 'testfile.xml');
    dbms_lob.createtemporary(l_clob, cache=>FALSE);
    dbms_lob.open(l_bfile, dbms_lob.lob_readonly);
    dbms_lob.loadFromFile(dest_lob => l_clob,
    src_lob => l_bfile,
    amount => dbms_lob.getLength(l_bfile));
    dbms_lob.close(l_bfile);
    insert into test_xml_rawdata values(xmltype.createxml(l_clob));
    commit;
    end;
    My query is:
    select extractvalue(value(b),'/datafeed/@deliverydate') ddate, extractvalue(value(b),'/datafeed/@vendorid') vendorid,
    extractvalue( value( c ), '//@feed_id') feed_id,
    extractvalue( value( a ), '//@empbased') empbased,
    extractvalue( value( a ), '//emp') emp,
    extractvalue( value( a ), '//value') value,
    extractvalue( value( a ), '//unit') unit,
    extractvalue( value( a ), '//date') ddate1,
    extract( value( a ), '//links/link/url') url,
    extract( value( a ), '//links/link/description') description
    from tbl_xml_rawdata t,
    table(xmlsequence(extract(t.xml_content,'/datafeed/items/item/content'))) a,
    table(xmlsequence(extract(t.xml_content,'/'))) b ,
    table(xmlsequence(extract(t.xml_content,'/datafeed/items/item'))) c;
    If the above query is run, the feed_id is cartesian joined with other data ,which is wrong.
    How should I go with this so that I can have 1 relational record with respect to each element & sub-elements.
    Also, if this is not doable in SQL, can someone direct me to some plsql example to do this. I read that dbms_xmldom & dbms_xmlparser can be used to travel through XML doc but I don't know how to use them.
    Any help please ??

    I'm still getting the same error while installing Oracle Patch set 9.2.0.6. I downloaded the patchset 2 weeks back.
    Pls help where download the correct version ?

  • Loading data into multiple tables - Bulk collect or regular Fetch

    I have a procedure to load data from one source table into eight different destination tables. The 8 tables have some of the columns of the source table with a common key.
    I have run into a couple of problems and have a few questions where I would like to seek advice:
    1.) Procedure with and without the BULK COLLECT clause took the same time for 100,000 records. I thought I would see improvement in performance when I include BULK COLLECT with LIMIT.
    2.) Updating the Load_Flag in source_table happens only for few records and not all. I had expected all records to be updated
    3.) Are there other suggestions to improve the performance? or could you provide links to other posts or articles on the web that will help me improve the code?
    Notes:
    1.) 8 Destination tables have at least 2 Million records each, have multiple indexes and are accessed by application in Production
    2.) There is an initial load of 1 Million rows with a subsequent daily load of 10,000 rows. Daily load will have updates for existing rows (not shown in code structure below)
    The structure of the procedure is as follows
    Declare
    dest_type is table of source_table%ROWTYPE;
    dest_tab dest_type ;
    iCount NUMBER;
    cursor source_cur is select * from source_table FOR UPDATE OF load_flag;
    BEGIN
    OPEN source_cur;
    LOOP
    FETCH source_cur -- BULK COLLECT
    INTO dest_tab -- LIMIT 1000
    EXIT WHEN source_cur%NOTFOUND;
    FOR i in dest_tab.FIRST .. dest_tab.LAST LOOP
    <Insert into app_tab1 values key, col12, col23, col34 ;>
    <Insert into app_tab2 values key, col15, col29, col31 ;>
    <Insert into app_tab3 values key, col52, col93, col56 ;>
    UPDATE source_table SET load_flag = 'Y' WHERE CURRENT OF source_cur ;
    iCount := iCount + 1 ;
    IF iCount = 1000 THEN
    COMMIT ;
    iCount := 0 ;
    END IF;
    END LOOP;
    END LOOP ;
         COMMIT ;
    END ;
    Edited by: user11368240 on Jul 14, 2009 11:08 AM

    Assuming you are on 10g or later, the PL/SQL compiler generates the bulk fetch for you automatically, so your code is the same as (untested):
    DECLARE
        iCount NUMBER;
        CURSOR source_cur is select * from source_table FOR UPDATE OF load_flag;
    BEGIN
        OPEN source_cur;
        FOR r IN source_cur
        LOOP
            <Insert into app_tab1 values key, col12, col23, col34 ;>
            <Insert into app_tab2 values key, col15, col29, col31 ;>
            <Insert into app_tab3 values key, col52, col93, col56 ;>
            UPDATE source_table SET load_flag = 'Y' WHERE CURRENT OF source_cur ;
            iCount := iCount + 1 ;
            IF iCount = 1000 THEN
                COMMIT ;
                iCount := 0 ;
            END IF;
            END LOOP;
        COMMIT ;
    END ;However most of the benefit of bulk fetching would come from using the array with a FORALL expression, which the PL/SQL compiler can't automate for you.
    If you are fetching 1000 rows at a time, purely from a code simplification point of view you could lose iCount and the IF...COMMIT...END IF and just commit each time after looping through the 1000-row array.
    However I'm not sure how committing every 1000 rows helps restartability, even if your real code has a WHERE clause in the cursor so that it only selects rows with load_flag = 'N' or whatever. If you are worried that it will roll back all your hard work on failure, why not just commit in your exception handler?

  • Inserting Lots of fields into multiple tables

    Hi, i would like to enter lots of fields into mutiple tables
    in my access database. I have 6 pages which in turn have a
    different set of forms which must be inserted into its own table. I
    tried to insert some information into the table but because my
    database is a relational db i get an error message "You cannot add
    or change a record because a related record is required in table
    'Hosting'. Im not entirely sure what this error means but it is
    quite urgent that this is sorted. Another way in which i tried it
    was to carry all the form values over each page and recarry them
    onto the final 'insert' page but i cannot insert more than one
    insert record behavior and if i do i get a dim error message.
    Can somebody please help me this is very urgent.
    Thanks in advance,
    Adam

    Adam
    The error means that you are trying to insert a record into a
    table that is
    dependent upon some of the information being in a higher
    table, so you need
    to do the inserts in the correct order.
    There is an old tutorial on the MM site on how to handle
    multiple tabel
    inserts, which you may find useful.
    Paul Whitham
    Certified Dreamweaver MX2004 Professional
    Adobe Community Expert - Dreamweaver
    Valleybiz Internet Design
    www.valleybiz.net
    "muzicmistro" <[email protected]> wrote in
    message
    news:e3fej1$8gp$[email protected]..
    > Hi, i would like to enter lots of fields into mutiple
    tables in my access
    > database. I have 6 pages which in turn have a different
    set of forms which
    > must
    > be inserted into its own table. I tried to insert some
    information into
    > the
    > table but because my database is a relational db i get
    an error message
    > "You
    > cannot add or change a record because a related record
    is required in
    > table
    > 'Hosting'. Im not entirely sure what this error means
    but it is quite
    > urgent
    > that this is sorted. Another way in which i tried it was
    to carry all the
    > form
    > values over each page and recarry them onto the final
    'insert' page but i
    > cannot insert more than one insert record behavior and
    if i do i get a dim
    > error message.
    >
    > Can somebody please help me this is very urgent.
    >
    > Thanks in advance,
    >
    > Adam
    >

  • Loading data into multiple tables from an excel

    Can we load data in to multiple tables at a time from an excel through Utilities? If yes how? Please help me
    Regards,
    Pallavi

    I would imagine that the utilities allow you to insert data from a spreadsheet into 1 and only 1 table.
    You may have to write your own custom data upload using External Tables and a PL/SQL procedure to insert data from 1 spreadsheet into more than 1 table.
    If you need any guidance on doing this let me know and I will happily point you in the right direction.
    Regards
    Duncan

Maybe you are looking for