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.

Similar Messages

  • Inserting large xml data into xmltype

    Hi all,
    In my project I need to insert very large XML data into xmltype column.
    My table:
    CREATE TABLE TransDetailstblCLOB ( id number, data_xml XMLType) XmlType data_xml STORE AS CLOB;
    I am using JDBC approach to insert values. It works fine for data less than 4000 bytes when using preparedStatement.setString(1, xmlData). As I have to insert large Xml data >4000 bytes I am now using preparedStatement.setClob() methods.
    My code works fine for table which has column declared as CLOB expicitly. But for TransDetailstblCLOB where the column is declared as XMLTYPE and storage option as CLOB I am getting the error : "ORA-01461: can bind a LONG value only for insert into a LONG column".
    This error means that there is a mismatch between my setClob() and column. which means am I not storing in CLOB column.
    I read in Oracle site that
    When you create an XMLType column without any XML schema specification, a hidden CLOB column is automatically created to store the XML data. The XMLType column itself becomes a virtual column over this hidden CLOB column. It is not possible to directly access the CLOB column; however, you can set the storage characteristics for the column using the XMLType storage clause."
    I dont understand its stated here that it is a hidden CLOB column then why not I use setClob()? It worked fine for pure CLOB column (another table) then Why is it giving such error for XMLTYPE table?
    I am struck up with this since 3 days. Can anyone help me please?
    My code snippet:
    query = "INSERT INTO po_xml_tab VALUES (?,XMLType(?)) ";
              //query = "INSERT INTO test VALUES (?,?) ";
         // Get the statement Object
         pstmt =(OraclePreparedStatement) conn.prepareStatement(query);
         // pstmt = conn.prepareStatement(query);
         //xmlData="test";
    //      If the temporary CLOB has not yet been created, create new
         temporaryClob = oracle.sql.CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION);
         // Open the temporary CLOB in readwrite mode to enable writing
         temporaryClob.open(CLOB.MODE_READWRITE);
         log.debug("tempClob opened"+"size bef writing data"+"length "+temporaryClob.getLength()+
                   "buffer size "+temporaryClob.getBufferSize()+"chunk size "+temporaryClob.getChunkSize());
         OutputStream out = temporaryClob.getAsciiOutputStream();
         InputStream in = new StringBufferInputStream(xmlData);
    int length = -1;
    int wrote = 0;
    int chunkSize = temporaryClob.getChunkSize();
    chunkSize=xmlData.length();
    byte[] buf = new byte[chunkSize];
    while ((length = in.read(buf)) != -1) {
    out.write(buf, 0, length);
    wrote += length;
    temporaryClob.setBytes(buf);
    log.debug("Wrote lenght"+wrote);
         // Bind this CLOB with the prepared Statement
         pstmt.setInt(1,100);
         pstmt.setStringForClob(2, xmlData);
         int i =pstmt.executeUpdate();
         if (i == 1) {
         log.debug("Record Successfully inserted!");
         }

    try this, in adodb works:
    declare poXML CLOB;
    BEGIN
    poXML := '<OIDS><OID>large text</OID></OIDS>';
    UPDATE a_po_xml_tab set podoc=XMLType(poXML) WHERE poid = 102;
    END;

  • 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 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.

  • Its very urgent:how to insert data into database tables

    Hi All,
    I am very new to oaf.
    I have one requirement data insert into database tables.
    here createPG having data that data insert into one custom table.
    but i dont know how to insert data into database tables.
    i wrote the code in am,co as follows.
    in am i wrote the code:
    public void NewoperationManagerLogic()
    ManagerCustomTableVOImpl vo1=getManagerCustomTableVO1();
    OADBTransaction oadbt=getOADBTransaction();
    if(!vo1.isPreparedForExecution())
    vo1.executeQuery();
    Row row=vo1.createRow();
    vo1.insertRow(row);
    in createPG processrequest co:
    public void processRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processRequest(pageContext, webBean);
    ManagerInformationAMImpl am=(ManagerInformationAMImpl)pageContext.getApplicationModule(webBean);
    am.NewoperationManagerLogic();
    process form request:
    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processFormRequest(pageContext, webBean);
    if(pageContext.getParameter("Submit")!=null)
    ManagerInformationAMImpl am=(ManagerInformationAMImpl)pageContext.getApplicationModule(webBean);
    am.getOADBTransaction().commit();
    please help with an example(sample code).
    its very urgent.
    thanks in advance
    Seshu
    Edited by: its urgent on Dec 25, 2011 9:31 PM

    Hi ,
    1.)You must have to create a EO based on custom table and then VO based on this EO eventually to save the values in DB
    2.) the row.setNewRowState(Row.STATUS_INITIALIZED); is used to set the the status of row as inialized ,this is must required.
    3.) When u will create the VO based on EO the viewattributes will be created in VO which will be assigned to the fields to take care the db handling .
    You must go thtough the lab excercise shipped with you Jdeveloper ,there is a example of Create Employee page ,that will solve your number of doubts.
    Thanks
    Pratap

  • How to insert large xml file to XMLType column?

    Hi,
    I have a table with one column as XMLType(Binary XML storage option and Free Text Indexing). When i try to insert a large XML as long as 8kb, i'm getting an error ORA-01704:string literal too long.
    Insert into TEST values(XMLTYPE('xml HERE'));
    How to insert large XML values to XMLType column?
    Regards,
    Sprightee

    For a large XML file, you basically have two options - you can load the string directly as an XMLType, or you can load the string as a CLOB and cast it on the database side to an XMLType.
    If you decide to load the XML as XmlType client-side, then you may be interested to know that versions of Oracle after 11.2.0.2 support the JDBC 4.0 SQLXML standard. See the JDBC driver release documentation here:
    http://docs.oracle.com/cd/E18283_01/java.112/e16548/jdbcvers.htm#BABGHBCC
    If you want to load as a CLOB, then you'll need to use PreparedStatement's setClob() method, or allocate an oracle.sql.clob object.
    For versions before 11.2.0.2, you can create an XMLType with a constructor that includes an InputStream or byte[] array.
    HTH
    Edited by: 938186 on Jun 23, 2012 11:43 AM

  • How to load xml data into a table

    Hi,
    i am a newbie. I want to insert the data of xml file into a table. I am doing this using XSU api for java.
    I am using oracle 9i and jdk 1.7.
    I am using OracleXmlSave class.
    but i am getting following error.
    java.lang.NoClassDefFoundError: oracle/jdbc2/Clob
    Please help in this regard. this is my first thread.
    thanks.
    Edited by: 979682 on Jan 3, 2013 3:39 AM

    Hi,
    You can insert XML data from XML file to Oracle database by this script :
    Hi,
    For reading and inserting the data from XML file to Oracle Database :
    1. CREATE A BLANK TABLE with same structure as XML file :
    select * from xml_test
    2. SELECT QUERY DIRECTLY ON XML FILE :
    SELECT XMLTYPE(bfilename('TEST_DIR', 'data_file.xml'), nls_charset_id('UTF8')) xml_data FROM dual
    3. CREATE ORACLE DIRECTORY AND PLACE XML FILE IN THIS DIRECTORY LOCATION:
    --CREATE DIRECTORY TEST_DIR as '/oracle/test';
    --grant all on directory TEST_DIR to public;
    4. INSERT THE XML DATA IN ORACLE TABLE:
    INSERT INTO xml_test(column1,coumn2)
    WITH t AS (SELECT XMLTYPE(bfilename('TEST_DIR', 'attachment.xml'), nls_charset_id('UTF8')) xml_col FROM dual)
    SELECT
    extractValue(value(x),'/ROW/COLUMN1') column1
    ,extractValue(value(x),'ROW/COLUMN2') column2
    FROM t,TABLE(XMLSequence(extract(t.xml_col,'/ROWSET/ROW'))) x;
    I have assumed a table with 2 columns.
    Regards,
    Rohit Chaudhari
    [email protected]

  • How to store XML data into Oracle Table

    I had trouble to store XML data into Oracle Table with XDK (Oracle 8.1.7 ). The error is:
    C:\XDK_Java_9_2\xdk\demo\java\Test>java testInsert Dept.xml
    <Line 1, Column 1>: XML-0108: (Fatal Error) Start of root element expected.
    Exception in thread "main" oracle.xml.sql.OracleXMLSQLException: Start of root element expected.
    at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:2263)
    at oracle.xml.sql.dml.OracleXMLSave.insertXML(OracleXMLSave.java:1333)
    at testInsert.main(testInsert.java:8)
    Here is my xml file:
    <?xml version = '1.0'?>
    <ROWSET>
    <ROW num="1">
    <DEPTNO>10</DEPTNO>
    <DNAME>ACCOUNTING</DNAME>
    <LOC>NEW YORK</LOC>
    </ROW>
    <ROW num="2">
    <DEPTNO>20</DEPTNO>
    <DNAME>RESEARCH</DNAME>
    <LOC>DALLAS</LOC>
    </ROW>
    <ROW num="3">
    <DEPTNO>30</DEPTNO>
    <DNAME>SALES</DNAME>
    <LOC>CHICAGO</LOC>
    </ROW>
    <ROW num="4">
    <DEPTNO>40</DEPTNO>
    <DNAME>OPERATIONS</DNAME>
    <LOC>BOSTON</LOC>
    </ROW>
    </ROWSET>
    and here is structure of table:
    Name Null? Type
    DEPTNO NOT NULL NUMBER(2)
    DNAME VARCHAR2(14)
    LOC VARCHAR2(13)
    and here is my Java Code:
    import java.sql.*;
    import oracle.xml.sql.dml.OracleXMLSave;
    public class testInsert{
         public static void main(String[] args) throws SQLException{
              Connection conn = getConnection();
              OracleXMLSave sav = new OracleXMLSave(conn,"scott.tmp_dept");
              sav.insertXML(args[0]);
              sav.close();
              conn.close();
         private static Connection getConnection()throws SQLException{
              DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
              Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@amt-ebdev01:1521:mydept","scott","tiger");
              return conn;
    Could you help me ? Thanks !

    The problem is that you need to pass avalid URL , Document...
    Please try this code instead:
    import java.net.*;
    import java.sql.*;
    import java.io.*;
    import oracle.xml.sql.dml.OracleXMLSave;
    public class testInsert
    public static void main(String[] args) throws SQLException{
    Connection conn = getConnection();
    OracleXMLSave sav = new OracleXMLSave(conn,"scott.temp_dept");
    URL url = createURL(args[0]);
    sav.insertXML(url);
    sav.close();
    conn.close();
    private static Connection getConnection()throws SQLException{
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@dlsun1982:1521:jwxdk9i","scott","tiger");
    return conn;
    // Helper method to create a URL from a file name
    static URL createURL(String fileName)
    URL url = null;
    try
    url = new URL(fileName);
    catch (MalformedURLException ex)
    File f = new File(fileName);
    try
    String path = f.getAbsolutePath();
    // This is a bunch of weird code that is required to
    // make a valid URL on the Windows platform, due
    // to inconsistencies in what getAbsolutePath returns.
    String fs = System.getProperty("file.separator");
    if (fs.length() == 1)
    char sep = fs.charAt(0);
    if (sep != '/')
    path = path.replace(sep, '/');
    if (path.charAt(0) != '/')
    path = '/' + path;
    path = "file://" + path;
    url = new URL(path);
    catch (MalformedURLException e)
    System.out.println("Cannot create url for: " + fileName);
    System.exit(0);
    return url;

  • 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.

  • Inporting XML data into a table

    I have the followiing XML document
    <?xml version="1.0" encoding="utf-8"?>
    <agents count="1382">
    <agent>
    <name>Nancy Palmer</name>
    <email>[email protected]</email>
    <agentid>MLSL:00525350</agentid>
    <officeid>58</officeid>
    <website>http://www.nancypalmer.com</website>
    <photo>https://sites.e-agents.com/Uploads/68/41/6841/Agents/agent_8418_NANCY_PALMER_COLOR_HEAD_SHOT_HIGH_QUALITY_2011.jpg</photo>
    <phone_direct>6504344313</phone_direct>
    <phone_cell>6504920200</phone_cell>
    <mod_time>2012-08-31T05:15:06.933</mod_time>
    </agent>
    <agent>
    <name>Genella Williamson</name>
    <email>[email protected]</email>
    <agentid>MLSL:00755754</agentid>
    <officeid>58</officeid>
    <website>http://www.apr.com/genella</website>
    <photo>https://sites.e-agents.com/Uploads/68/41/6841/Agents/agent_8426_genella.jpg</photo>
    <phone_direct>6504344319</phone_direct>
    <phone_cell>6507870839</phone_cell>
    <mod_time>2010-10-30T15:15:07.603</mod_time>
    </agent>
    <agent>
    <name>Diana Langley</name>
    <email>[email protected]</email>
    <agentid>MLSL:01256202,SFAR:805608</agentid>
    <officeid>50</officeid>
    <website>http://www.apr.com/DLangley</website>
    <photo>https://sites.e-agents.com/Uploads/68/41/6841/Agents/agent_7848_dlangley.jpg</photo>
    <phone_direct/>
    <phone_cell/>
    <mod_time>2011-06-06T05:15:06.587</mod_time>
    </agent>
    </agents>
    I want to load it to the following table
    SQL> desc apr_agent
    Name Null? Type
    NAME VARCHAR2(100)
    EMAIL VARCHAR2(100)
    OFFICEID VARCHAR2(50)
    WEBSITE VARCHAR2(1000)
    PHOTO VARCHAR2(1000)
    PHONE_DIRECT VARCHAR2(100)
    PHONE_CELL VARCHAR2(100)
    MOD_DATE VARCHAR2(100)
    SQL>
    So I created a directory
    create or replace directory APR_STG as '/opt/smarteragent/procdata/APR';
    and I created the following insert statement
    INSERT INTO apr_agent
    (NAME, email, officeid, website, photo, phone_direct, phone_cell, mod_date)
    WITH T AS (SELECT XMLTYPE(BFILENAME('APR_STG','agents.xml'), NLS_CHARSET_ID('AL32UTF8')) xmlcol FROM dual)
    SELECT EXTRACTVALUE(VALUE(x),'/ROW/name') NAME,
    EXTRACTVALUE(VALUE(x),'/ROW/email') email,
    EXTRACTVALUE(VALUE(x),'ROW/officeid') officeid,
    EXTRACTVALUE(VALUE(x),'ROW/website') website,
    EXTRACTVALUE(VALUE(x),'ROW/photo') photo,
    EXTRACTVALUE(VALUE(x),'ROW/phone_direct') phone_direct,
    EXTRACTVALUE(VALUE(x),'ROW/phone_cell') phone_cell,
    EXTRACTVALUE(VALUE(x),'ROW/mod_time') mod_date
    FROM T,TABLE(XMLSEQUENCE(EXTRACT(T.xmlcol,'/ROWSET/ROW'))) x;
    I am currently getting now rows inserted. Not sure why?
    Any help would be greatly appreciated.

    Well, if you were to run the SELECT statement alone (from WITH on down), you would see that it is returning 0 rows. After some head-scratching and searching you would come to realize it is because your XPaths are not finding any data in the XML. In your XPaths, you are looking for a root node of ROWSET with a child of ROW. In the XML, the root node is agents and the child is agent. Assuming you are on 10.2 or later, your SELECT statement itself could be written as
    SELECT NAME, email,
           officeid, website,
           photo, phone_direct,
           phone_cell, mod_date
      FROM XMLTable('/agents/agent'
                    PASSING XMLType(BFILENAME('APR_STG','agents.xml'), NLS_CHARSET_ID('AL32UTF8'))
                    COLUMNS
                    NAME         VARCHAR2(100) PATH 'name',
                    email        VARCHAR2(100) PATH 'email',
                    officeid     VARCHAR2(50) PATH 'officeid',
                    website      VARCHAR2(1000) PATH 'website',
                    photo        VARCHAR2(1000) PATH 'photo',
                    phone_direct VARCHAR2(100) PATH 'phone_direct',
                    phone_cell   VARCHAR2(100) PATH 'phone_cell',
                    mod_date     VARCHAR2(100) PATH 'mod_time');and then you could just append that to your INSERT so you have something like
    INSERT INTO apr_agent
    (NAME, email, officeid, website, photo, phone_direct, phone_cell, mod_date)
    SELECT NAME, email,....If the count of 1382 is to be believed, then you may start wondering why your INSERT is taking so long to process. Performance will depend upon many factors.
    If you are on 11g (any of them), then you have an option to improve performance over 10.2 and earlier versions. You simply create a table, it could even be a Global Temporary Table that looks something like
    create table TEMP_XML (XML_DATA xmltype)
    xmltype column XML_DATA store as securefile binary xml;(if on 11.2.0.2 or later, you only need)
    create table TEMP_XML (XML_DATA xmltype);Then you insert the XML data into it via
    INSERT INTO TEMP_XML VALUES XMLType(BFILENAME('APR_STG','agents.xml'), NLS_CHARSET_ID('AL32UTF8')));and change the above SELECT statement to read from that table instead, such as
    SELECT NAME, email,
           officeid, website,
           photo, phone_direct,
           phone_cell, mod_date
      FROM TEMP_XML tx
           XMLTable('/agents/agent'
                    PASSING tx.xml_data
    ...And then you'll be done with that task.
    Note: Only the first SQL statement was verified, the rest should be valid but have not been executed/verified.

  • Loading XML files into Database table

    Loading XML files into Database table
    Hi I have some XML files say 100 files in a virtual directory created using &quot;Create or replace directory command&quot; and those files need to be loaded into a table having a column of XMLTYPE. 1)How to load that using Oracle provided procedures/packages

    Check out the Oracle XDB Developer's Guide, Chapter 3. There is an example of using BFileName function to load the xml files from a directory object created using create or replace directory. It works really well.
    Ben

  • 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

  • How to Insert a record in a database table in debugging mode in production

    Hi,
    How to Insert a record in a database table in debugging mode in production ?
    Waiting for kind response.
    Best Regards,
    Padhy
    Moderator Message : Duplicate post locked.
    Moderator message : Warning. Don't create multiple threads for same question.
    Edited by: Vinod Kumar on May 12, 2011 11:02 AM
    Edited by: Vinod Kumar on May 12, 2011 11:04 AM

    Hi Senthil,
    Regards,
    Phani Raj Kallur
    Message was edited by: Phani Raj Kallur

  • Load xml data into database

    Hi,
    I need to load the xml data into the relational tables. I was trying to use a DOM parser, but the thing is that i had to hard code the element node values to match the columns in the tables, and in later stage if there is change to the xml i have to change my program and recompile, i want a more flexible solution, where in i can parse the data and load into database without much changes. I do not know how to accomplish this. I have searched on this topic, but could not find a clear solution anywhere. Can anybody suggest a solution to this.
    Thanks & regards.

    For which database?
    With the Oracle database an XML document may be stored in a database with the XML SQL (XSU) utility.
    1. Create a table in the database with columns corresponding to the elements in the XML document.
    2. With the XSU store the XML document. The attributes in the XML document do not get stored.
    3. To store the attributes also, apply an XSLT to the XML document and convert the attributes to elements.

  • How to maintain the data  into database table

    Hi,
    experts,
    how to maintain the data  into database table

    There are several ways to maintain data in the database
    1. Use table maintanance generator . You can create this using SE11 and data can be edited through SM30.
    2. Loginto  SE11 with the specified table and check the ATTRIBUTES tab. There you can set some parameters for maintaining the database. When you set Maintain database, you edit the data thorugh SE11 it self
    3. Through Se16 as well.
    4. A small abap program can do the above task as well.
    Thanks,
    Raj
    Edited by: Rajanya Kolavennu on Feb 5, 2008 8:33 PM

Maybe you are looking for

  • PrintPreview for a GridControl ?

    Hello guys, I like to show a PrintPreview of a GridControl. So user could see the style of GridControl before printing. I found a peace of code as a class that we can instantiate it to view a printPreviw of a "JTable". It works fine when I pass JTabl

  • [SOLVED]Intel Xorg Fail

    Hi everyone, I've found I can no longer start X (just a black screen, no cursor) on my Thinkpad X201 with Intel graphics. It was working fine earlier today (though I did update when this happened), and I've retraced anything I've changed as best I ca

  • Battery not recognised - and other issues with 867MHz Ti Book

    Ok - here`s my story - I wonder if anyone can give me advice on what to do next. A week ago I started having trackpad issues with my tibook. On 2 consecutive mornings the trackpad seemed to have frozen, held down. So that it brought up menus if the m

  • Installing boot camp on a second drive

    Hi All, First let me apologize for this long-winded post and also for my lack of basic knowledge when it comes to mac computer skills. I would like to install windows 7 on a brand new 500gb drive in a brand new mac pro. I was reading through the inst

  • Iphone 4 Midnight Release??

    Today i spoke with someone frm my local walmart nd they said they might have a midnight release. Can anyone confirm this?? And what are the chances of this happening??