InsertXML()

Hi!
I'm inserting XML file into DB using OracleXMLSave - insertXML().
I wonder if there is limit of number of columns to handle at once.
When I pass a rowset with about 150 columns of data to insertXML(), DB(Oracle) stops and do nothing. No error messages.
Here is a segment of my code :
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn = DriverManager.getConnection(DB_URL, DB_USERID, DB_PASSWORD);
xs = new OracleXMLSave(conn,tableName);
xs.setIgnoreCase(true);
xs.setDateFormat("dd-MMM-yyyy");
rValue = xs.insertXML(xmlDoc);
xs.close();
conn.commit();
conn.close();
The table, which data is inserted into, has about 200 columns, but generally 100 columns of them are inserted from XML doc.
It means, in most cases, it works fine.
But, I have to be able to deal with 150 columns or more.
Any idea?
null

insertXML() wants an XML Document as an argument.
You can give it:
A DOM Document object (in-memory, already parsed).
An inputstream (useful if you're getting the XML from a file or servlet request or something)
Where you are currently "printing tags" into a printwriter to "make" your XML, you can do one of two things:
(1) Change your code to create Elements
instead of printing the XML tag
representation of the Elements.
XMLDocument newDoc = new XMLDocument();
Element docElt = newDoc.createElement("DATASET");
newDoc.appendChild(docElt);
// Then for each time you would have
// printing a <DATA>value</DATA>
// you do instead:
Element newDataElt = newDoc.createElement("DATA");
newDataElt.appendChild(newDoc.createTextNode( valueVariable );
Then you can give "newDoc" to insertXML().
(2) You can print your document as text
into a big string, and then
create a ByteArrayInputStream on the
string to pass to insertXML()
ByteArrayInputStream bais = new ByteArrayInputStream(yourXMLString.getBytes());
insertXML(bais);
Number 1 should be more efficient because
you avoid parsing.

Similar Messages

  • White space handling dbms_xmlstore.insertxml

    Hi,
    I have a question about white space handling.
    I have a column in table which holds white space character.
    When I loading xml file using dbms_xmlstore.insertxml white space is converted into NULL and inserted into table.
    It would fail if the column type is not null.
    How do I handle it?
    ======================================================
    Alternatively, how do I insert a tag with only whitespace in it into a table?
    <Tag> </Tag> [One whitespace]
    To elaborate the question
    If I have following data in xml file ...
    =============================================
    <Rowset>
    <Row>
    <Tag1> </Tag1>
    <Tag2>1</Tag1>
    </Row>
    </Rowset>
    I have to load this data into
    table tab1...
    create table tab1 (tag1 varchar2(5), tag2 number);
    How do I achieve it using dbms_xmlstore so that I can read the whitespace in XML and load it correctly into the table?
    ========================================================================
    To use an alternate approach, I also tried the following.....
    I tried the following test program on the xml file also shown below....
    XML File is
    <?xml version="1.0"?>
    <ROWSET>
    <ROW>
    <SYS_NAME> a </SYS_NAME>
    <SYS_SERIAL_NUM>000000</SYS_SERIAL_NUM>
    </ROW>
    </ROWSET>
    And small procedure is
    create or replace procedure PRO_TEST
    as
    o_sys_name varchar(10);
    spacetag varchar2(10) := ' ';
    begin
    --execute immediate 'create global temporary table gt_xmltype_tab1 (xmlfile1 xmltype)';
    insert into gt_xmltype_tab(xmlfile1)
    values(XMLType(bfilename('RESTOREDIR','ADTL_SETUP_OPTIONS.xml'),nls_charset_id('AL32UTF8')));
    select extractvalue (value(x), '/ROW/SYS_NAME')
    into o_sys_name
    from gt_xmltype_tab gt, TABLE(XMLSequence(extract(gt.xmlfile1, '/ROWSET/ROW'))) x;
    dbms_output.put_line('[' || o_sys_name || ']');
    dbms_output.put_line('ASCII:- ' || ascii(o_sys_name));
    if o_sys_name = ' ' then
    --if o_sys_name = chr(32) then
    dbms_output.put_line('I found space');
    else
    dbms_output.put_line('I found no space');
    end if;
    commit;
    end;
    When Tag is <sys_nam> </sys_name> I get [] in the output(empty).
    When Tag is <sys_nam> a</sys_name> I get [ a] in the output(space and a).
    When Tag is <sys_nam> a </sys_name> I get [ a ] in the output(space a space).
    When I has some character along with the whitespace, behaviour is correct and as expected.
    But when the tag contains only whitespace the output is empty.
    I cant seem to get around this problem.
    Upon receiving empty string, other sub systems which are reading the data stop working.
    Can someone help here?
    Edited by: userAtoZ on May 14, 2011 2:57 PM

    White space handling dbms_xmlstore.insertxmlYou may replace all whitespaces with its corresponding html entity:
    SQL> create table test (v varchar2 (5))
    Table created.
    SQL> declare
      ctx   sys.dbms_xmlstore.ctxtype := dbms_xmlstore.newcontext ('test');
      doc   xmltype := xmltype(replace('<ROW><V> </V></ROW>',' ', '&#38;#32;'));
      ret   int;
    begin
      ret := dbms_xmlstore.insertxml (ctx, doc);
      dbms_xmlstore.closecontext (ctx);
    end;
    PL/SQL procedure successfully completed.
    SQL> select v, length (v), ascii(v) from test
    V             LENGTH(V)        ASCII(V)
                          1              32
    1 row selected.

  • Error while using dbms_xmlsave.UpdateXML and dbms_xmlsave.insertXML

    The Record I am trying to insert/update has the following structure
    <ROWSET>
    <ROW>
    <COL1>123</COL1>
    </ROW>
    </ROWSET>
    Table structure is as below
    COL1 INT [Primary constraint]
    COL2 VARCHAR2(100) NOT NULL [but has default value of 'COL2_Default']
    Now since the XML doesn't have the entry for COL2, I am explicitly setting the columns to be updated/inserted using dbms_xmlsave.setUpdateColumn.
    I use the logic the following logic to insert/update the table
    -- set the primary key column name. This forms the where clause for update statement
    dbms_xmlsave.setkeycolumn(l_Context , 'COL1');
    -- cXML have the XML structure mentioned above
    l_rows := dbms_xmlsave.updateXML(l_Context, cXML);
    IF l_rows <= 0 THEN -- which means no rows found for update
    l_rows := dbms_xmlsave.insertXML(l_Context, cXML);
    END IF;
    Now when the excution of dbms_xmlsave.updateXML happens Java Runtime Error is thrown.
    ORA-29532: Java call terminated by uncaught Java exception: oracle.xml.sql.OracleXMLSQLException: 'java.sql.SQLException: Missing IN or OUT parameter at index:: 5' encountered during processing ROW element 0. All prior XML row changes were rolled back. in the XML document.
    The version of oracle I am using is 9.2.0.6.0.
    Please let me know if anyone has any idea on this error.

    Found maybe an applicable reference...
    On http://publib.boulder.ibm.com/infocenter/wasinfo/v4r0/index.jsp?topic=/com.ibm.support.was.doc/html/Java_2_Connectivity_(J2C)/1163246.html
    it says:
    * Application code is missing a setXXX method call somewhere.
    * There might be a problem in the Oracle JDBC driver code.
    If the latter is the problem than you should or try a different JDBC driver or (which is probably the best solution anyway) create an iTar with Oracle support via metalink.oracle.com
    Other references can also be found on the internet when using google which could be applicable. Search on keywords: "Missing IN or OUT parameter at index"
    Message was edited by:
    mgralike

  • Problem using insertXML with Reader  (XSU utility)

    I am having an issue with the insertXML method of OracleXMLSave class when using a java.io.Reader argument. The source xml stream contains a DOCTYPE declaration, which causes the following error when I run my process:
    XML-20112: (Fatal Error) Error opening external DTD './dtd/Devices.dtd'.
    oracle.xml.sql.OracleXMLSQLException: no protocol: ./dtd/Devices.dtd
         at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:2383)
         at oracle.xml.sql.dml.OracleXMLSave.insertXML(OracleXMLSave.java:1373)
    Apparently the path to the DTD file cannot be resolved, even though there is an appropriate dtd file in the subdirectory as listed.
    If I use the other version of insertXML that takes a URL and load the same xml file from a file system, everything works fine.
    Outside of taking an interim step to remove the DOCTYPE declaration, is there any way to solve this problem?
    Any advice would be appreciated... thanks!

    Deepak;
    Thanks for the reply.
    Where would I make this specification?
    I am currently doing the following:
         try {
    Connection conn = getConnection();
    OracleXMLSave sav = new OracleXMLSave(conn, tableName);
    sav.setUpdateColumnList(colNames); // set the columns to update.
    sav.setRowTag(rowTag);
    sav.setIgnoreCase(true);
    // set xslt
    Reader xsltReader;
         try {
              xsltReader = new FileReader(new File("c:/attr2elem.xsl"));
              sav.setXSLT(xsltReader, null);
         } catch (FileNotFoundException e) {
              e.printStackTrace();
    sav.insertXML(xmlData);
    ... more code ...
    The xmlData is a stream that contains the dtd that is attempting to be referenced.
    How do I specify the DTD that is contained within that stream as a file URL?
    Regards,
    --Chris                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Using dbms_xmlsave.insertXML

    Hi all,
    I am reading an XML data which has similar structure to:
    <dept>
    <name> department name </name>
    <loc> department location </loc>
    <emp>
    <fisrt> first name for first employee </first>
    <last> last name for first employee </last>
    </emp>
    <emp>
    <first> first name for second employee </first>
    <last> last name for second employee </last>
    </emp>
    </dept>
    I do not have control on the structure of the XML data as I am reading it from external source. Now I have created a table as follows:
    SQL> create type emprec as object (
    first varchar2(30),
    last varchar2(30)
    SQL> create type empreclist as table of emprec;
    SQL> create table mydept (
    name varchar2(30),
    loc varchar2(50),
    emp empreclist);
    Now when I use the dbms_xmlsave.insertXML , the columns name,loc are populated but the column emp is not populated and i I define the emp column as (emprec) type, then only the last <emp></emp> data is inserted.
    Any ideas how to read all the <emp></emp> data into the dept table ?

    Hi,
    I have been trying for a while to get a nested collection loaded. The oracle documentation is no help. But what i did in the end is this. I built the object table, inserted the nested collection manual and then ran the command line XSU (documented in the app. dev. guide xml) to save the tabledata as XML (only one record) with the -withDTD switch. This creates a XML with inline DTD. Surprise surprise when you load that document it does work, even when you add more nested rows in the document. This XML file will also show you if you build the table correctly. It seems that XSU needs the DTD to be able to load nested collections.
    If you are running windows the command line utility can be run like this
    java -cp c:\oracle\ora81\rdbms\jlib\xsu12.jar;c:\oracle\ora81\lib\xmlparserv2.jar;c:\oracle\ora81\jdbc\lib\classes12.zip OracleXML getXML -user "username/password" -withDTD "select * from yourtable" >g:\xmlfiles\output.xml
    have fun

  • DBMS_XMLSave.insertXML slow.

    Hi,
    I am using the function DBMS_XMLSave.insertXML to take a clob (XML file) off a queue, and process
    the file into a table. I am finding that inserting 10,000 records (from a single clob) is taking over 30secs.
    This is an order of magnitude out from where I expected to be. It would be nice (clean) to
    be able to order my App this way using XML documents and Advanced Queues, but if I cant get the times
    down further I will need to look at other alternatives.
    Is there a way to improve the performance of DBMS_XMLSave.insertXML?
    Thanks,
    Matt

    Lucky boy, you have DBMS_XMLSave in sys schema, I have not....
    Did you try to use dbms_xmlsave.setBatchSize ? Set about 10% of total xml size (in bytes). This should improve performace greatelly.

  • DBMS_XMLSave.insertXML Fails on decimal format

    DBMS_XMLSave.insertXML Fails on decimal format
    The following example fails when using collections of complex elements. The error is:
    java.lang.NumberFormatException: 1.0'
    Example is:
    create table test_parent(p_id NUMBER(18),
    test_col number(10))
    alter table test_parent add constraint pk1 primary key(p_id)
    create table test_child(t_id NUMBER(18),
    test_col number(10),
    p_id NUMBER(18))
    alter table test_child add constraint pk2 primary key(t_id)
    alter table test_child add constraint fk1 foreign key (p_id) references test_parent(p_id)
    insert into test_parent values(1,1)
    insert into test_child values(1,1,1)
    insert into test_child values(2,2,1)
    insert into test_child values(3,3,1)
    create type test_c AS OBJECT (t_id NUMBER(18),test_col NUMBER(10));
    CREATE OR REPLACE TYPE test_cs AS TABLE OF test_c
    CREATE OR REPLACE VIEW test_view(parent_id,parent_num,child)
    AS SELECT p.P_id,
    p.test_col,
    CAST(MULTISET(SELECT c.t_id,
    c.test_col
    FROM test_child c
    WHERE p.p_id = c.p_id) AS test_cs) AS child
    FROM test_parent P
    CREATE OR REPLACE TRIGGER test_trig INSTEAD OF INSERT ON test_view
    BEGIN
    DBMS_OUTPUT.PUT_LINE('Trigger proccessing');
    END;
    SHOW ERRORS
    DECLARE
    insCtx DBMS_XMLSave.ctxType;
    rows number;
    xmlDoc CLOB := '<ROWSET>
    <ROW>
    <PARENT_ID>2.0</PARENT_ID>
    <PARENT_NUM>2.0</PARENT_NUM>
    <CHILD>
    <T_ID>1.0</T_ID>
    <TEST_COL>1.0</TEST_COL>
    </CHILD>
    </ROW>
    </ROWSET>';
    BEGIN
    insCtx := DBMS_XMLSave.newContext('TEST_VIEW');
    rows := DBMS_XMLSave.insertXML(insCtx,xmlDoc);
    DBMS_XMLSave.closeContext(insCtx);
    END;
    DECLARE
    insCtx DBMS_XMLSave.ctxType;
    rows number;
    xmlDoc CLOB := '<?xml version="1.0"?>
    <ROWSET>
    <ROW>
    <PARENT_ID>1</PARENT_ID>
    <PARENT_NUM>1</PARENT_NUM>
    <CHILD>
    <TEST_C>
    <T_ID>1.0</T_ID>
    <TEST_COL>1</TEST_COL>
    </TEST_C>
    <TEST_C>
    <T_ID>2</T_ID>
    <TEST_COL>2</TEST_COL>
    </TEST_C>
    <TEST_C>
    <T_ID>3</T_ID>
    <TEST_COL>3</TEST_COL>
    </TEST_C>
    </CHILD>
    </ROW>
    </ROWSET>';
    BEGIN
    insCtx := DBMS_XMLSave.newContext('TEST_VIEW');
    rows := DBMS_XMLSave.insertXML(insCtx,xmlDoc);
    DBMS_XMLSave.closeContext(insCtx);
    END;

    If you have access to ON, check out document 119140.1.
    Apparently it's a bug in the jdbc driver in pre-Oracle 8.1.7 databases...the workaround looks messy though.

  • DBMS_XMLSave.insertXML

    Hi All,
    I am using DBMS_XMLSave.insertXML to read a XMl file and store it in a table.
    But the maximum record I am able to insert into the oracle table is limited around 80...
    I have tried using DBMS_XMLSave.setBatchSize but it is not helping me.
    let me know if there is any way to increase the buffer?

    Lucky boy, you have DBMS_XMLSave in sys schema, I have not....
    Did you try to use dbms_xmlsave.setBatchSize ? Set about 10% of total xml size (in bytes). This should improve performace greatelly.

  • DBMS_XMLSave.insertXML ORA-01024 error

    DBMS_XMLSave.insertXML ORA-01024 error
    The following error is being produced when trying to use DBMS_XMLSave.insertXML. The xml datagram was produced from the view using DBMS_XMLQuery.getXML. This works fine for non object nested views.
    Does anyone know of a problem with this approach or syntax.
    Thanks
    ORA-29532: Java call terminated by uncaught Java exception:
    oracle.xml.sql.OracleXMLSQLException: 'oracle.jdbc.driver.OracleSQLException:
    ORA-01024: invalid datatype in OCI call
    ' encountered during processing ROW element 1. All prior XML row changes were
    rolled back. in the XML document.
    ORA-06512: at "SYSTEM.DBMS_XMLSAVE", line 91
    ORA-06512: at "SJS.IMRES", line 60
    ORA-06512: at "SJS.IMRES", line 99
    ORA-06512: at line 6
    *************** Insert Procedure *******************
    PROCEDURE InsertXml(xmlDoc IN clob, tableName IN VARCHAR2) IS
    insCtx DBMS_XMLSave.ctxType;
    rows number;
    BEGIN
    DBMS_OUTPUT.PUT_LINE('INsertXml - '||tableName);
    insCtx := DBMS_XMLSave.newContext(tableName);
    rows := DBMS_XMLSave.insertXML(insCtx,xmlDoc);
    dbms_output.put_line('InsertXML -'||rows);
    DBMS_XMLSave.closeContext(insCtx);
    COMMIT;
    END InsertXml;
    *************** Object view *******************
    CREATE OR REPLACE TYPE sjs.imres_error_type AS OBJECT
    ("ResponseErrorCode"     VARCHAR2(10),
    "ResponseErrorDesc"     VARCHAR2(4000))
    CREATE OR REPLACE TYPE sjs.imres_errors_type AS TABLE OF imres_error_type
    CREATE OR REPLACE VIEW sjs.imresponse
    AS SELECT ith.a_id AS "ArrestNumber",
    CAST(MULTISET(SELECT ire.errorcode,
    ire.errordesc
    FROM sjs.imresponseerrors ire
    WHERE ire.ith_id = ith.ith_id) AS imres_errors_type) AS "Errors"
    FROM sjs.imtransactionhistory ith
    *************** XML DATAGRAM *******************
    <?xml version = '1.0'?>
    <ROWSET>
    <ROW>
    <ArrestNumber>2</ArrestNumber>
    <Errors>
    <Errors_ITEM>
    <ResponseErrorCode>CODE 2</ResponseErrorCode>
    <ResponseErrorDesc>DESC 2</ResponseErrorDesc>
    </Errors_ITEM>
    <Errors_ITEM>
    <ResponseErrorCode>CODE 1</ResponseErrorCode>
    <ResponseErrorDesc>DESC 1</ResponseErrorDesc>
    </Errors_ITEM>
    </Errors>
    </ROW>
    </ROWSET>

    It seems to be related to an insert/update for the same context
    having different columns with "values" in it.
    I have 3 rows. For the AMT column the first row has 151.56,
    the second row has 100.00, the third row has .00
    The third row fails with this error :
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error
    ORA-06512: at "MTRSTEST.KIM_RTL_XML_PKG", line 150
    ORA-29532: Java call terminated by uncaught Java exception:
    oracle.xml.sql.OracleXMLSQLException:
    Invalid context handle specified.
    ORA-06512: at "SYS.DBMS_XMLQUERY", line 170
    ORA-06512: at "MTRSTEST.KIM_RTL_XML_PKG", line 193
    ORA-29532: Java call terminated by uncaught Java exception:
    oracle.xml.sql.OracleXMLSQLException:
    Expected 'EOF'.
    ORA-06512: at "MTRSTEST.KIM_TEST", line 197
    ORA-06512: at line 1
    If I change the third row to say 10.00, for example, it works
    fine.
    We had not been on xdk9 yet, I'm having them install xdk9 and
    we'll see if the problem persists.

  • Loading data into XMLType column using dbms_xmlsave.insertxml get ORA-29532

    The following simple test case succeeded in 9.2.0.1 but failed in 9.2.0.2.
    CREATE OR REPLACE procedure InsertXML(xmlDoc IN VARCHAR2, tableName IN VARCHAR2) is
    insCtx DBMS_XMLSave.ctxType;
    rows number;
    begin
    insCtx := DBMS_XMLSave.newContext(tableName); -- get the context handle
    rows := DBMS_XMLSave.insertXML(insCtx,xmlDoc); -- this inserts the document
    dbms_output.put_line(to_char(rows) || ' rows inserted');
    DBMS_XMLSave.closeContext(insCtx); -- this closes the handle
    end;
    CREATE TABLE XMLtable
    (column1 xmltype)
    exec insertxml('<?xml version = "1.0"?><ROWSET><ROW><COLUMN1><TEST>HELLO</TEST></COLUMN1></ROW></ROWSET>', 'XMLTABLE');

    Hi,
    For your XML file I think you just need to enclose XML elemnts in ROWSET AND ROW TAGS - so xml should look like :
    <ROWSET>
    <ROW>
    <DEPT>
    </DEPT>
    and just pass it as CLOB to dbms_xmlsave.insertXML proc.
    I hope it should work.
    I am also trying to insert XML file but with a bit complex structure having multiple nested elements.
    I am not sure how to transform the external XML file to wrap it in ROWSET/ROW using XSLT. It's mandatory to use ROWSET/ROW tags to be able to insert in oracle tables. I am facing this problem right now. I am using object views to accomplish the purpose but still needs to figure out the way to apply stylesheet to incoming XML file.
    If you come to know of any way, pls do let me know also.
    Thanks

  • Default insertion for missing elements using DBMS_XMLSave.insertXML

    Hi,
    I am trying to insert default values for some columns, without having those column names as elements in the xml document. Is it possible to do so?? This is the code I am using for now, but it inserts null values for missing elements in the xml document.
    insCtx := DBMS_XMLSave.newContext ('TABLENAME'); -- get the context
    rows := DBMS_XMLSave.insertXML (insCtx, p_xmlDoc); -- insert the doc
    DBMS_XMLSave.closeContext (insCtx); -- close the handle

    Only thing I noticed with dbms_xmlstore.insertXML, was when my xml document had "<?xml version = "1.0" ?>" at the start, it gave an error "LPX-00209: PI names starting with XML are reserved"That's probably due to the XML document not starting exactly with "&lt;", like this :
    SQL> DECLARE
      2
      3    xmldoc   clob := '
      4  <?xml version="1.0"?>
      5        <ROWSET>
      6       <ROW>
      7        <COL1>1</COL1>
      8        <COL2>TEST1</COL2>
      9       </ROW>
    10       <ROW>
    11       <COL1>2</COL1>
    12      </ROW>
    13     </ROWSET>';
    14
    15    ctx      dbms_xmlstore.ctxHandle;
    16    numrows  number;
    17
    18  BEGIN
    19
    20    ctx := dbms_xmlstore.newContext('MY_TABLE');
    21    numrows := dbms_xmlstore.insertXML(ctx, xmldoc);
    22    dbms_xmlstore.closeContext(ctx);
    23
    24  END;
    25  /
    DECLARE
    ERROR at line 1:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00209: PI names starting with XML are reserved
    ORA-06512: at "SYS.DBMS_XMLSTORE", line 78
    ORA-06512: at line 21 However, it runs OK if the prolog actually starts the character stream :
    SQL> DECLARE
      2
      3    xmldoc   clob := '<?xml version="1.0"?>
      4        <ROWSET>
      5       <ROW>
      6        <COL1>1</COL1>
      7        <COL2>TEST1</COL2>
      8       </ROW>
      9       <ROW>
    10       <COL1>2</COL1>
    11      </ROW>
    12     </ROWSET>';
    13
    14    ctx      dbms_xmlstore.ctxHandle;
    15    numrows  number;
    16
    17  BEGIN
    18
    19    ctx := dbms_xmlstore.newContext('MY_TABLE');
    20    numrows := dbms_xmlstore.insertXML(ctx, xmldoc);
    21    dbms_xmlstore.closeContext(ctx);
    22
    23  END;
    24  /
    PL/SQL procedure successfully completed.
    With the dbms_xmlsave.inserXML, [...] it wont insert the default column values.Now that's strange...
    I understand there could be differences in the parsing implementation, but in the end both processes must issue an INSERT into the target table using plain SQL, so I really wonder why default values are not applied.
    I'll try to reproduce when I have access to a Java-enabled db.

  • Can't replicate data inserted using DBMS_XMLSAVE.insertXML

    Enviroment:
    OS: SLES 10 SP2
    Database Version: 11.1.0.6
    I have configured an Oracle Streams environment compose by two database. The first is the source where a local capture process should captures dml changes from some tables. If I insert some data using a classic dml insert operation the changes are replicated without problems. The problem is when the tables are populated using the DBMS_XMLSAVE.insertXML procedure. With that implementation there isn't data replication. I think DBMS_XMLSAVE.insertXML must generate redolog so the capture process should capture the changes from them but it doesn't seems to be like that.
    I need some suggestion about this matter, thank you.

    Here you are
    CREATE TABLE TEST.HABI
    ID_DATA NUMBER,
    ID_HOCU INTEGER,
    ID_HABI INTEGER,
    DESCRIPTION VARCHAR2(1000 BYTE)
    TABLESPACE USERS
    PCTUSED 0
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 32M
    NEXT 80K
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    PCTINCREASE 0
    BUFFER_POOL DEFAULT
    LOGGING
    NOCOMPRESS
    NOCACHE
    NOPARALLEL
    MONITORING;
    I'am not performe explicit commit here you are the procedure:
    FUNCTION import(p_id_data IN INTEGER,
    p_lote IN INTEGER,
    p_fecha_hotel DATE,
    p_error IN OUT NOCOPY CLOB,
    p_hab_habi IN OUT NOCOPY CLOB,
    p_hcl_clie IN OUT NOCOPY CLOB,
    p_hcl_habi IN OUT NOCOPY CLOB,
    p_hcl_hist IN OUT NOCOPY CLOB,
    p_tel_llpr IN OUT NOCOPY CLOB) Return integer
    AS
    ctx DBMS_XMLSAVE.ctxType;
    v_rows NUMBER;
    v_err_msg VARCHAR(4000);
    v_cant integer;
    BEGIN
    IF length(p_error) > (length('<?xml version = ''1.0''?><ENL_TRAN_ERROR/>') + 3) THEN
    ctx := DBMS_XMLSAVE.newContext('ENL_TRAN_ERROR');
    DBMS_XMLSAVE.setRowTag(ctx, 'ROW');
    --BEGIN
    v_rows := DBMS_XMLSAVE.insertXML(ctx, p_error);
    --EXCEPTION WHEN OTHERS THEN
    -- NULL;
    --END;
    DBMS_XMLSAVE.closeContext(ctx);
    END IF;
    IF length(p_hab_habi) > (length('<?xml version = ''1.0''?><ENL_TRAN_HAB_HABI/>') + 3) THEN
    ctx := DBMS_XMLSAVE.newContext('ENL_TRAN_HAB_HABI');
    DBMS_XMLSAVE.setRowTag(ctx, 'ROW');
    --BEGIN
    v_rows := DBMS_XMLSAVE.insertXML(ctx, p_hab_habi);
    --EXCEPTION WHEN OTHERS THEN
    -- NULL;
    --END;
    DBMS_XMLSAVE.closeContext(ctx);
    END IF;
    IF (INSTR(p_hcl_clie, '&')<>0) THEN
    p_hcl_clie := replace(p_hcl_clie, '&', '&amp;');
    END IF;
    IF length(p_hcl_clie) > (length('<?xml version = ''1.0''?><ENL_TRAN_HCL_CLIE/>') + 3) THEN
    ctx := DBMS_XMLSAVE.newContext('ENL_TRAN_HCL_CLIE');
    DBMS_XMLSAVE.setRowTag(ctx, 'ROW');
    --BEGIN
    v_rows := DBMS_XMLSAVE.insertXML(ctx, p_hcl_clie);
    --EXCEPTION WHEN OTHERS THEN
    -- NULL;
    --END;
    DBMS_XMLSAVE.closeContext(ctx);
    END IF;
    IF length(p_hcl_habi) > (length('<?xml version = ''1.0''?><ENL_TRAN_HCL_HABI/>') + 3) THEN
    ctx := DBMS_XMLSAVE.newContext('ENL_TRAN_HCL_HABI');
    DBMS_XMLSAVE.setRowTag(ctx, 'ROW');
    --BEGIN
    v_rows := DBMS_XMLSAVE.insertXML(ctx, p_hcl_habi);
    --EXCEPTION WHEN OTHERS THEN
    -- NULL;
    --END;
    DBMS_XMLSAVE.closeContext(ctx);
    END IF;
    IF length(p_hcl_hist) > (length('<?xml version = ''1.0''?><ENL_TRAN_HCL_HABI_HIST/>') + 3) THEN
    ctx := DBMS_XMLSAVE.newContext('ENL_TRAN_HCL_HABI_HIST');
    DBMS_XMLSAVE.setRowTag(ctx, 'ROW');
    --BEGIN
    v_rows := DBMS_XMLSAVE.insertXML(ctx, p_hcl_hist);
    --EXCEPTION WHEN OTHERS THEN
    -- NULL;
    --END;
    DBMS_XMLSAVE.closeContext(ctx);
    END IF;
    IF length(p_tel_llpr) > (length('<?xml version = ''1.0''?><ENL_TRAN_TEL_LLPR/>') + 3) THEN
    ctx := DBMS_XMLSAVE.newContext('ENL_TRAN_TEL_LLPR');
    DBMS_XMLSAVE.setRowTag(ctx, 'ROW');
    --BEGIN
    v_rows := DBMS_XMLSAVE.insertXML(ctx, p_tel_llpr);
    --EXCEPTION WHEN OTHERS THEN
    -- NULL;
    --END;
    DBMS_XMLSAVE.closeContext(ctx);
    END IF;
    END import;
    I hope you can help me.

  • Inserting Date AND Time using DBMS_XMLStore.insertXML

    Hello,
    I'm using a c# app to create an xml file to be passed to a stored procedure. The store procedure then uses DBMS_XMLStore.insertXML to insert the record in the xml file into the database.
    There is a field in the Oracle table called "ENTER_DATE". I've been putting a date into the xml file for this field (ie. "10-mar-2010") and this has worked fine. However, I've now been asked to include the time with the date.
    Is it possible to somehow put a date AND time value in the xml tag value so that DBMS_XMLStore.insertXML will properly insert it into the Oracle table? Everything I try returns a date picture format error.
    Thanks

    SQL> create table dept2
    as
       select d.*, sysdate enter_date
         from dept d
        where 1 = 2
    Table created.
    SQL> select * from dept2
    no rows selected.
    SQL> alter session set nls_date_format='dd.mm.yyyy hh24:mi:ss'
    Session altered.
    SQL> declare
       ctx   dbms_xmlstore.ctxtype := dbms_xmlstore.newcontext ('dept2');
       doc  xmltype
          := xmltype('<START>
                   <ROW>
                     <DEPTNO>10</DEPTNO>
                     <DNAME>ACCOUNTING</DNAME>
                     <LOC>NEW YORK</LOC>
                     <ENTER_DATE>10.10.2010 23:11:16</ENTER_DATE>
                   </ROW>
                         </START>');
       ret   int;
    begin
       ret := dbms_xmlstore.insertxml (ctx, doc);
       dbms_xmlstore.closecontext (ctx);
    end;
    PL/SQL procedure successfully completed.
    SQL> select * from dept2
        DEPTNO DNAME          LOC           ENTER_DATE          
            10 ACCOUNTING     NEW YORK      10.10.2010 23:11:16 
    1 row selected.

  • InsertXML nested table

    Hello, I'm trying to insert to nested table xml clob using DBMS_XMLSave.insertXML.
    But xsu inserts to nested table for each row the same data !
    Are there any limitation to use DBMS_XMLSave.insertXML for nested table ?
    This is the xml I'm trying to insert, table dept have the same structure as xml with nested table emplist.
    (xml is generated with DBMS_XMLQuery ...,)
    | <ROWSET>
    | <ROW num="1">
    | <DEPTNO>1</DEPTNO>
    | <EMPLIST>
    | <EMPLIST_ITEM>
    | <EMPNO>1</EMPNO>
    | <ENAME>pkdahle</ENAME>
    | <SALARY>10</SALARY>
    | <EMPADDR>
    | <STREET>u</STREET>
    | <CITY>c</CITY>
    | <STATE>s </STATE>
    | <ZIP>z</ZIP>
    | </EMPADDR>
    | </EMPLIST_ITEM>
    | <EMPLIST_ITEM>
    | <EMPNO>2</EMPNO>
    | <ENAME>pkahle2</ENAME>
    | <SALARY>101</SALARY>
    | <EMPADDR>
    | <STREET>us</STREET>
    | <CITY>cc</CITY>
    | <STATE>sc</STATE>
    | <ZIP>zc</ZIP>
    | </EMPADDR>
    | </EMPLIST_ITEM>
    | </EMPLIST>
    | </ROW>
    | <ROW num="2">
    | <DEPTNO>2</DEPTNO>
    | <EMPLIST>
    | <EMPLIST_ITEM>
    | <EMPNO>1</EMPNO>
    | <ENAME>pkdahle</ENAME> -- this won't be saved in emplist (ename form previous row num=1 will be saved)
    | <SALARY>10</SALARY>
    | <EMPADDR>
    | <STREET>u</STREET>
    | <CITY>c</CITY>
    | <STATE>s </STATE>
    | <ZIP>z</ZIP>
    | </EMPADDR>
    | </EMPLIST_ITEM>
    | <EMPLIST_ITEM>
    | <EMPNO>2</EMPNO>
    | <ENAME>pkahle2</ENAME>
    | <SALARY>101</SALARY>
    | <EMPADDR>
    | <STREET>us</STREET>
    | <CITY>cc</CITY>
    | <STATE>sc</STATE>
    | <ZIP>zc</ZIP>
    | </EMPADDR>
    | </EMPLIST_ITEM>
    | </EMPLIST>
    | </ROW>
    | </ROWSET>
    Thank's

    I've created a simple example :
    1.Create types and table.
    2.Fill table with sample data
    3.Run queryCtx := DBMS_XMLQuery.newContext('select * from TestTable'); to generate XML
    4.delete testtable
    5.Run rows := DBMS_XMLSave.insertXML(insCtx,xmlDoc); with the generated xml.
    6.The table testtable will have 2 rows with the same 1 row collection xlist !!!
    CREATE OR REPLACE TYPE Test_Type
    AS OBJECT (
    x number
    create or replace type Test_List_Type as table of Test_Type
    create table TestTable (
    XX number,
    XLIst Test_List_Type
    nested table XLIst store as TestTable_XLIst_NEST
    insert into
    testtable
    (xx,xlist)
    values
    (1,Test_List_Type (test_type(10)))
    insert into
    testtable
    (xx,xlist)
    values
    (1,Test_List_Type (test_type(10)))
    insert into
    testtable
    (xx,xlist)
    values
    (2,Test_List_Type (test_type(20),test_type(21),test_type(22),test_type(23)))
    script to insert xml
    declare
    insCtx DBMS_XMLSave.ctxType;
    rows number;
    xmldoc clob;
    -- xxslt clob;
    begin
    select cclob into xmldoc from cc.ka_clob; -- (I've stored xml in this table)
    insCtx := DBMS_XMLSave.newContext('testtable'); -- get the context handle
    DBMS_XMLSave.Setignorecase(insctx,1);
    rows := DBMS_XMLSave.insertXML(insCtx,xmlDoc); -- this inserts the document
    DBMS_XMLSave.closeContext(insCtx); -- this closes the handle
    commit;
    end;

  • Help With InsertXML

    Hi,
    I am trying to Insert Data in Relational Tables using dbms_save package of Oracle. Here when i try and Insert date in the following format dd-mon-yy. it fails. When i change this format it works Fine. Is there any Fix for this solution. Help will be highly appreciated.
    Regards
    Prasanth

    DBMS_XMLSTORE should honor the current setting of NLS_DATE_FORMAT
    SQL> drop table DBMS_XMLSTORE_TEST
      2  /
    Table dropped.
    SQL> create table DBMS_XMLSTORE_TEST
      2  (
      3     ID number(2),
      4     DATE_VALUE date
      5  )
      6  /
    Table created.
    SQL> alter session set NLS_DATE_FORMAT= 'DD-MON-RR'
      2  /
    Session altered.
    SQL> declare
      2   insCtx DBMS_XMLStore.ctxType;
      3   rows NUMBER;
      4    xmldoc CLOB :=
      5  '<ROWSET>
      6     <ROW>
      7       <ID>1</ID>
      8       <DATE_VALUE>27-AUG-1996</DATE_VALUE>
      9     </ROW>
    10     <ROW>
    11       <ID>2</ID>
    12       <DATE_VALUE>31-DEC-1992</DATE_VALUE>
    13     </ROW>
    14  </ROWSET>';
    15
    16  BEGIN
    17
    18     insCtx := DBMS_XMLStore.newContext('DBMS_XMLSTORE_TEST');
    19
    20     DBMS_XMLStore.setUpdateColumn(insCtx,'ID');
    21     DBMS_XMLStore.setUpdatecolumn(insCtx,'DATE_VALUE');
    22
    23     rows := DBMS_XMLStore.insertXML(insCtx, xmlDoc);
    24     commit;
    25
    26     DBMS_XMLStore.closeContext(insCtx);
    27
    28  END;
    29  /
    PL/SQL procedure successfully completed.
    SQL> select * from DBMS_XMLSTORE_TEST
      2  /
            ID DATE_VALU
             1 27-AUG-96
             2 31-DEC-92
    SQL> alter session set NLS_DATE_FORMAT= 'YYYY-MM-DD'
      2  /
    Session altered.
    SQL> select * from DBMS_XMLSTORE_TEST
      2  /
            ID DATE_VALUE
             1 1996-08-27
             2 1992-12-31
    SQL> declare
      2   insCtx DBMS_XMLStore.ctxType;
      3   rows NUMBER;
      4    xmldoc CLOB :=
      5  '<ROWSET>
      6     <ROW>
      7       <ID>3</ID>
      8       <DATE_VALUE>2006-01-31</DATE_VALUE>
      9     </ROW>
    10     <ROW>
    11       <ID>4</ID>
    12       <DATE_VALUE>2006-02-01</DATE_VALUE>
    13     </ROW>
    14  </ROWSET>';
    15
    16  BEGIN
    17
    18     insCtx := DBMS_XMLStore.newContext('DBMS_XMLSTORE_TEST');
    19
    20     DBMS_XMLStore.setUpdateColumn(insCtx,'ID');
    21     DBMS_XMLStore.setUpdatecolumn(insCtx,'DATE_VALUE');
    22
    23     rows := DBMS_XMLStore.insertXML(insCtx, xmlDoc);
    24     commit;
    25
    26     DBMS_XMLStore.closeContext(insCtx);
    27
    28  END;
    29  /
    PL/SQL procedure successfully completed.
    SQL> select * from DBMS_XMLSTORE_TEST
      2  /
            ID DATE_VALUE
             1 1996-08-27
             2 1992-12-31
             3 2006-01-31
             4 2006-02-01
    SQL> alter session set NLS_DATE_FORMAT= 'DD-MON-RR'
      2  /
    Session altered.
    SQL> select * from DBMS_XMLSTORE_TEST
      2  /
            ID DATE_VALU
             1 27-AUG-96
             2 31-DEC-92
             3 31-JAN-06
             4 01-FEB-06
    SQL>

  • InsertXML setDateFormat error

    I'm getting an error when using insertxml and my xml document has dates in it. I have
    set the procedure "setDateFormat" to the
    appropriate date mask. I have tried many different date formats and the only way I can get it to work is when there are no dates in the xml document. I have attached a test script and the resulting error.
    Thanks in advance
    Rodger
    declare
    xmlString CLOB := null;
    rowsp integer;
    v_xml_out varchar2(32000);
    begin
    v_xml_out := '<ORDER_STATUS>
    <order_detail>
    <ORDS_WEB_ORDER_NBR>WEB-ORD-12345</ORDS_WEB_ORDER_NBR>
    <ORDS_WEB_CUSTOMER_NBR>WEB-CUST-12345</ORDS_WEB_CUSTOMER_NBR>
    <ORDS_CUSTOMER_NAME>Rodger Winger</ORDS_CUSTOMER_NAME>
    <ORDS_COMPANY_ID>MUS</ORDS_COMPANY_ID>
    <ORDS_DOC_DATE_TIME>12-Dec-00</ORDS_DOC_DATE_TIME>
    <ORDS_DOC_ID>DOC-ID-123</ORDS_DOC_ID>
    <ORDS_RMA_NBR>RMA-NBR-123</ORDS_RMA_NBR>
    <ORDS_PRODUCT_QTY>100</ORDS_PRODUCT_QTY>
    <ORDS_BACKORDERED_QTY>25</ORDS_BACKORDERED_QTY>
    <ORDS_SHIPPED_QTY>40</ORDS_SHIPPED_QTY>
    <ORDS_RETURN_QTY>10</ORDS_RETURN_QTY>
    <ORDS_RETURN_REASON>Return-Reason</ORDS_RETURN_REASON>
    <ORDS_REFUND_DISPOSITION>Ref-Disp-1</ORDS_REFUND_DISPOSITION>
    <ORDS_LINE_NBR>1</ORDS_LINE_NBR>
    <ORDS_SKU>SKU-12345</ORDS_SKU>
    <ORDS_STATUS>Status-321</ORDS_STATUS>
    <ORDS_SHIP_METHOD_CODE>FEDEX-ON</ORDS_SHIP_METHOD_CODE>
    <ORDS_CREATION_DATE></ORDS_CREATION_DATE>
    <ORDS_CANCELLED_QTY>3</ORDS_CANCELLED_QTY>
    <ORDS_ITEM_AVAILABLE_DATE></ORDS_ITEM_AVAILABLE_DATE>
    <ORDS_TRACKING_NBR>ORDS-TRK-NBR-123</ORDS_TRACKING_NBR>
    <ORDS_LOT_NBR>ORDS-LOT-NBR-789</ORDS_LOT_NBR>
    <ORDS_SERIAL_NBR>ORDS-SRL-NBR-657</ORDS_SERIAL_NBR>
    <ORDS_REASON>Order Status Reason</ORDS_REASON>
    <ORDS_CONTAINER_NBR>65</ORDS_CONTAINER_NBR>
    <ORDS_EXPECTED_ARRIVAL_DATE></ORDS_EXPECTED_ARRIVAL_DATE>
    <ORDS_MSG_TRANSACTION_TYPE>ORDERSTATUS</ORDS_MSG_TRANSACTION_TYPE>
    <ORDS_CRTNG_MSG_ID>100</ORDS_CRTNG_MSG_ID>
    <ORDS_MSG_COMPANY_ID>MUS</ORDS_MSG_COMPANY_ID>
    </order_detail>
    </ORDER_STATUS>';
    DBMS_LOB.CREATETEMPORARY(xmlString,TRUE, DBMS_LOB.SESSION);
    DBMS_LOB.WRITEAPPEND (xmlString, length(v_xml_out), v_xml_out);
    -- open the lob
    dbms_lob.open(xmlString,DBMS_LOB.LOB_READONLY);
    -- before inserting , make sure that the case is ignored (since we generated everything with lower case)
    xmlgen.resetOptions;
    xmlgen.setRowTag('order_detail');
    xmlgen.setIgnoreTagCase(xmlgen.IGNORE_CASE);
    xmlgen.setDateFormat('DD-MON-YY');
    -- insert the XML document
    rowsp := xmlgen.insertXML('ords_order_statuses',xmlString);
    dbms_output.put_line(' Rows processed = '&#0124; &#0124; TO_CHAR(rowsp));
    -- free the lob
    dbms_lob.close(xmlString);
    dbms_lob.freetemporary(xmlString);
    end;
    error message
    ERROR at line 1:
    ORA-29532: Java call terminated by uncaught Java exception:
    oracle.xml.sql.OracleXMLSQLException: Unparseable date: "12-Dec-00"
    ORA-06512: at "XMLOWNER20.XMLGEN", line 114
    ORA-06512: at line 61

    You have to use the date format masks that are defined at:
    http://java.sun.com/products/jdk/1.1/docs/api/java.text.SimpleDateFormat.html
    which are difference from the standard Oracle date masks.
    For dates of the form 12-Dec-00, the mask would be (case-sensitive!):
    d-M-yy
    null

Maybe you are looking for

  • Document flow says "Acct determin error".  The invoice not posted in FI

    Hello SAP gurus, Having an issue with my sales order (IJ1 single instance client 100 system) The document flow is saying "Acct determin error" and in the header status - billing document Invoice posting says "Not posted in FI". checked MM03 settings

  • Project resource Management: Discoverer reports for Utilization.

    Hello, We are planning to use PJRs discoverer reports. Is it mandatory to use PJI for the same? Also what is the exact difference in new and old utilizaiton models? It will be great f you can point me to some proper docs on this one. thanks fo ryour

  • "3265 du process" appears and disappears and ***** a lot of CPU System usage: what is that?

    Opening activity monitor, I see a process that appears and disappears, called 3265 "du" process. It ***** a lot of CPU % system (the red one in the mac activity monitor utility). Anyone knows what's that and how can I remove it? probably it's the sam

  • Bizarre mouse behavior on rollOut - bug??

    I built a custom cursor out of a swf file and I am applying it on rollover to a specific item. That part works fine. The problem is the on rollOut event (or mouseOut I've tried both same exact behavior) fires CONTINUOUSLY when I move the mouse to the

  • Adding keywords to eps, ai, pdf & jpeg

    Hi I'm new to bridge and I'm also new to keywords/tagging so I need little help. I'm trying to tag files with keywords then upload them to a service called fluxiom (which is like an online portfolio). Fluxiom allows you to search your files by keywor