SQL Xml issue in ojdbc 6 (11.2.0.3.0)

I have a SYS.XMLTYPE column in one of my tables and trying to use hibernate to insert and retrieve from the same..
A stand alone test code inserts and retrieves successfully.. when I use
SQLXML sqlXML = preparedStmt.getConnection().createSQLXML(); // while inserting
SQLXML sqlXML = rs.getSQLXML(names [0]); // while retrieving..
But when the same is deployed in a server jboss as 7.1 / websphere 7.. I am able to insert properly but retrieval is giving me a Null pointer both in jboss and websphere..
Caused by: java.lang.NullPointerException
at oracle.jdbc.driver.NamedTypeAccessor.getOracleObject(NamedTypeAccessor.java:678)
at oracle.jdbc.driver.NamedTypeAccessor.getSQLXML(NamedTypeAccessor.java:992)
at oracle.jdbc.driver.OracleResultSetImpl.getSQLXML(OracleResultSetImpl.java:3028)
at oracle.jdbc.driver.OracleResultSet.getSQLXML(OracleResultSet.java:1299)
Can somebody help!!...

Hello,
Is there a solution to this issue ?
I have similar pb with this code :
PL/SQL :
procedure P_FIND_xxx_XML(
pa_1 t_table.v_field1%type,
pa_2 t_table.v_field2_version%type,
pa_3 t_table.v_field3%type,
pa_4 t_table.v_field4%type,
pa_5 t_table.n_field5%type,
pa_6 t_table.n_field6%type,
pa_7 OUT SYS_REFCURSOR
JAVA:
Connection tmpConnection = null;
CallableStatement tmpStatement = null;
ResultSet tmpResultSet = null;
SQLXML tmpSqlXml = null;
tmpConnection = getConnection();
tmpStatement = tmpConnection.prepareCall("{call pa_xxx.p_find_xxx_xml(?,?,?,?,?,?,?)}");
tmpStatement.setString(1, p1);
tmpStatement.setString(2, p2);
tmpStatement.setString(3, p3);
tmpStatement.setString(4, p4);
tmpStatement.setLong(5, p5);
tmpStatement.setLong(6, p6);
tmpStatement.registerOutParameter(7, OracleTypes.CURSOR);
tmpStatement.execute();
tmpResultSet = ((OracleCallableStatement)tmpStatement).getCursor(7);
while(tmpResultSet.next())
tmpPKId = (tmpResultSet).getLong(1);
if(tmpPKId != null)
getLogger().info("performHistory --> " + "tmpPKId <" + tmpPKId + ">");
tmpSqlXml = (tmpResultSet).getSQLXML(2);
if(tmpSqlXml != null)
getLogger().info("performHistory --> " + "tmpSqlXml <NOT NULL OBJECT>");
else
getLogger().info("performHistory --> " + "tmpSqlXml <NULL OBJECT>");
the code tmpPKId = (tmpResultSet).getLong(1); is OK and i have the value
The (tmpResultSet).getSQLXML(2) throw an exception :
java.lang.NullPointerException
at oracle.jdbc.driver.NamedTypeAccessor.getOracleObject(NamedTypeAccessor.java:302)
at oracle.jdbc.driver.NamedTypeAccessor.getSQLXML(NamedTypeAccessor.java:413)
at oracle.jdbc.driver.OracleResultSetImpl.getSQLXML(OracleResultSetImpl.java:1251)
Any idea ?

Similar Messages

  • Strange Behavior with SQL/XML

    Our University have had for quite some time now a rather difficult situation with a very significant course handbook web site that creates HTML based on database XSL transformation of XML content generated with SQL/XML. The database is 10.2.0.2.0. The HTML is passed via a distributed database link to an Oracle Portal dynamic portlet for display. Some of the derived XML originates from XML Schema registered instance documents and some from relational storage.
    Let me explain. Occasionally after a period of operating (could be one week, sometimes even less) we will experience a problem whereby our derived XML content (just prior to PL/SQL database XSL transformation) will develop a parsing problem. Once this happens to one XSL transform of a course then subsequently it happens for every course viewed/transformed there-after.
    Recently I experienced the problem and then added the XMLNS argument to the extract function. That seemed to fix things and I thought I had it licked.
    Today we started to get the same problem again. The error reported was:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00242: invalid use of ampersand ('&') character (use &amp;)
    Error at line 1
    Now this might have been reasonable for one course. But every course reported the same problem there-after without fail. I managed to fix the issue but in a way that really doesn't seem to make sense. What I did was to alter the SQL/XML statement by adding in an extra XMLEMENT and then to recompile the function that returns an XMLTYPE based on the execution of the SQL statement. After compiling the function everything returned to normal.
    This doesn't seem to make sense.
    I am pretty desperate for help on this. I really don't know how to progress the solution. I don't get much joy from Oracle Support as our application covers too many high tech areas. This is really shaking confidence in our organization's use of Oracle technology.

    Hi Mark.
    We've isolated the problem a bit more now and there is a support SR (6089662.994). At this stage we are unable to reproduce - I am testing out an export though. The problem only occurs when a certain condition has been reached. Once that happens then extraneous characters are produced in the XMLTYPE feed returned by a function. We are not at all sure about how to make this condition occur. This doesn't just happen with one SQL/XML cursor - I've seen it happen with 3 different cursors. All are located in the same function that returns an XMLTYPE.
    We are convinced the problem lies with one or more SQL/XML cursors located in the same function. Once one of these cursors malfunctions it will produce XML that is not well formed OR on occasion has content omitted but is well formed (there often seem to be extraneous characters). When the XML content is not well formed then the parsing stage (dbms_xmlparser.parseclob(myparser, xml_clob)) of XSL transformation crashes. This error then propagates to the dynamic portlet in Oracle Portal thus removing the content on the page. This happens for every execution of the cursor while the condition manifests, the only difference between calls being bind variables.
    The interesting thing is that the error if left to itself will eventually stop. The cursor seems to right itself eventually. On the last occurrence, the problem commenced at 4.30am and went for 3.5 hrs and then seemed to right itself.

  • SQL/XML performance and xdbcore-parameter

    Hello,
    I try to figure out, what the best method to retrieve large XML-Documents is.
    I compare performance and resources needed for: SQL/XML, DBMS_XMLGEN, SYS_XMLGEN and XSU.
    With a fixed set of 1000 rows I created XML of about 32 MB.
    I am on 10.2.0.4 on Linux
    XML is not schema based.
    SQL*Plus: Release 10.1.0.4.2 - Production on Fri Aug 21 13:35:42 2009
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, Data Mining and Real Application Testing optionsWhat I see, is that SQL/XML is the slowest and needs huge PGA amount (160 Mb and seems to increase linearly, for 5000 rows I've measured ~800 Mb).
    As I've read here, memory issues with SQL/XML should have been solved in 9.2.0.3 (?)
    Is this the case? Or is this PGA amount ok?
    I would like also to test the impact of xdbcore-xobmem-bound and xdbcore-loadableunit-size parameters.
    But I cannot observe any impact. Must I restart the database everytime after change of xdbconfig.xml?
    But also after increasing from 1024 16 to resp. 10240 5120 and restart the same speed and memory consumption are in place.
    Am I doing something wrong?

    SQL*Loader: Release 11.2.0.2.0 - Production on H. Febr. 11 18:57:09 2013
    Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
    Control File: prodxml.ctl
    Character Set UTF8 specified for all input.
    Data File: test.xml
    Bad File: test.bad
    Discard File: none specified
    (Allow all discards)
    Number to load: ALL
    Number to skip: 0
    Errors allowed: 5000
    Bind array: 64 rows, maximum of 256000 bytes
    Continuation: none specified
    Path used: Conventional
    Table PRODUCT_XML, loaded from every logical record.
    Insert option in effect for this table: APPEND
    Column Name Position Len Term Encl Datatype
    COL_ID FIRST 1000 CHARACTER
    (FILLER FIELD)
    IN_FILE DERIVED * EOF CHARACTER
    Static LOBFILE. Filename is bv_test.xml
    Character Set UTF8 specified for all input.
    SQL*Loader-605: Non-data dependent ORACLE error occurred -- load discontinued.
    ORA-01652: unable to extend temp segment by 128 in tablespace TEMP
    Table PRODUCT_XML:
    0 Rows successfully loaded.
    0 Rows not loaded due to data errors.
    0 Rows not loaded because all WHEN clauses were failed.
    0 Rows not loaded because all fields were null.
    Space allocated for bind array: 256 bytes(64 rows)
    Read buffer bytes: 1048576
    Total logical records skipped: 0
    Total logical records rejected: 0
    Total logical records discarded: 0
    Run began on H. Febr. 11 18:57:09 2013
    Run ended on H. Febr. 11 19:20:54 2013
    Elapsed time was: 00:23:45.76
    CPU time was: 00:05:05.50
    this is the log
    i have truncated everything i am not able to load 400 mega into 4 giga i cannot understand
    windows is not licensed 32 bit

  • Very basic SQL/XML question

    I'm using the following environment:
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE 10.2.0.1.0 Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    However, I don't think my environment is the issue.
    I'm trying to get output which looks like this from a simple table:
    <MAXDOMAIN action="S">
         <DOMAINID key="true">domainid_data</DOMAINID>
         <SYNONYMDOMAIN type="relationship" action="AU" >
              <VALUE key="true">value_data</VALUE>
              <MAXVALUE>maxvalue_data</MAXVALUE>
              <DESCRIPTION>description_data</DESCRIPTION>
              <DEFAULTS>defaults_data</DEFAULTS>
         </SYNONYMDOMAIN>
    </MAXDOMAIN>The table looks like this
    Name                           Null     Type          
    DOMAINID                       NOT NULL VARCHAR2(30)   
    DESCRIPTION                             VARCHAR2(50)   
    DOMAINTYPE                              VARCHAR2(5)    
    MAXTYPE                                 VARCHAR2(5)    
    LENGTH                                  VARCHAR2(5) The real question is how do I get an element with attributes to also have content.
    <DOMAINID key="true">domainid_data</DOMAINID>and
    <VALUE key="true">value_data</VALUE>I'm not sure if I'm syntactically challenged or just not using the correct tags.
    If I try to just generate the first two tags, forgetting the following nesting, I'm OK, as long as I don't try to assign attributes to the DOMAINID tag:
    SELECT  XMLELEMENT
    ("MAXDOMAIN",XMLATTRIBUTES('S' AS "action"),XMLELEMENT(NAME DOMAINID, "DOMAINID")
    AS "RESULT"
    FROM FAC_MAXDOMAIN;This works and is pretty trivial.
    <MAXDOMAIN action="S"><DOMAINID>AIRFLOWTYPE</DOMAINID></MAXDOMAIN>
    etc, etc...However, this:
    SELECT  XMLELEMENT
    ("MAXDOMAIN",XMLATTRIBUTES('S' AS "action"),XMLELEMENT(NAME DOMAINID, "DOMAINID",XMLATTRIBUTES('true' AS "key"))
    AS "RESULT"
    FROM FAC_MAXDOMAIN;Yields an ORA-00907: missing right parenthesis error.
    Any ideas? maybe a good primer on SQL/XML might be the best solution...
    TIA,
    Paolo

    Very nice for a first post in terms of data included and formatting.
    It took me a few minutes to see it, but the simple answer is you are putting the XMLAttributes in the wrong location. See the XMLElement spec at http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions220.htm#SQLRF06168 that shows XMLAttributes comes between the identifier and value. So that means you should have written it as
    Connected to Oracle Database 11g Enterprise Edition Release 11.1.0.6.0
    SQL> WITH FAC_MAXDOMAIN AS
      2  (SELECT 'domainid_data' domainid, 'dscr' description,
      3          'type' domaintype, '10' maxtype, '5' length
      4     FROM dual)
      5  -- Using WITH so didn't have to create your table locally
      6  SELECT  XMLELEMENT("MAXDOMAIN",
      7            XMLATTRIBUTES('S' AS "action"),
      8            XMLELEMENT(NAME DOMAINID, XMLATTRIBUTES('true' AS "key"), "DOMAINID")
      9          )
    10  AS "RESULT"
    11  FROM FAC_MAXDOMAIN;
    RESULT
    <MAXDOMAIN action="S"><DOMAINID key="true">domainid_data</DOMAINID></MAXDOMAIN>

  • Error while running PL/SQL XML Parser Samples

    every time try to run the PL/SQL XML Parser Sample program i get this error no file or directory, though the file and dir exists, i have the permissions setup as in readme.txt do i need to do any chnages to init.ora,
    pls advice
    Thanks,
    SQL> exec test
    begin test; end;
    ERROR at line 1:
    ORA-20100: Error occurred while parsing: No such file or directory
    ORA-06512: at "SCOTT.XMLPARSER", line 22
    ORA-06512: at "SCOTT.XMLPARSER", line 69
    ORA-06512: at "SCOTT.TEST", line 13
    ORA-06512: at line 1

    Which examples in particular? Thanks.

  • SQL Performance issue: Using user defined function with group by

    Hi Everyone,
    im new here and I really could need some help on a weird performance issue. I hope this is the right topic for SQL performance issues.
    Well ok, i create a function for converting a date from timezone GMT to a specified timzeone.
    CREATE OR REPLACE FUNCTION I3S_REP_1.fnc_user_rep_date_to_local (date_in IN date, tz_name_in IN VARCHAR2) RETURN date
    IS
    tz_name VARCHAR2(100);
    date_out date;
    BEGIN
    SELECT
    to_date(to_char(cast(from_tz(cast( date_in AS TIMESTAMP),'GMT')AT
    TIME ZONE (tz_name_in) AS DATE),'dd-mm-yyyy hh24:mi:ss'),'dd-mm-yyyy hh24:mi:ss')
    INTO date_out
    FROM dual;
    RETURN date_out;
    END fnc_user_rep_date_to_local;The following statement is just an example, the real statement is much more complex. So I select some date values from a table and aggregate a little.
    select
    stp_end_stamp,
    count(*) noi
    from step
    where
    stp_end_stamp
    BETWEEN
    to_date('23-05-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')      
    AND
    to_date('23-07-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')
    group by
    stp_end_stampThis statement selects ~70000 rows and needs ~ 70ms
    If i use the function it selects the same number of rows ;-) and takes ~ 4 sec ...
    select
    fnc_user_rep_date_to_local(stp_end_stamp,'Europe/Berlin'),
    count(*) noi
    from step
    where
    stp_end_stamp
    BETWEEN
    to_date('23-05-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')      
    AND
    to_date('23-07-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')
    group by
    fnc_user_rep_date_to_local(stp_end_stamp,'Europe/Berlin')I understand that the DB has to execute the function for each row.
    But if I execute the following statement, it takes only ~90ms ...
    select
    fnc_user_rep_date_to_gmt(stp_end_stamp,'Europe/Berlin','ny21654'),
    noi
    from
    select
    stp_end_stamp,
    count(*) noi
    from step
    where
    stp_end_stamp
    BETWEEN
    to_date('23-05-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')      
    AND
    to_date('23-07-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')
    group by
    stp_end_stamp
    )The execution plan for all three statements is EXACTLY the same!!!
    Usually i would say, that I use the third statement and the world is in order. BUT I'm working on a BI project with a tool called Business Objects and it generates SQL, so my hands are bound and I can't make this tool to generate the SQL as a subselect.
    My questions are:
    Why is the second statement sooo much slower than the third?
    and
    Howcan I force the optimizer to do whatever he is doing to make the third statement so fast?
    I would really appreciate some help on this really weird issue.
    Thanks in advance,
    Andi

    Hi,
    The execution plan for all three statements is EXACTLY the same!!!Not exactly. Plans are the same - true. They uses slightly different approach to call function. See:
    drop table t cascade constraints purge;
    create table t as select mod(rownum,10) id, cast('x' as char(500)) pad from dual connect by level <= 10000;
    exec dbms_stats.gather_table_stats(user, 't');
    create or replace function test_fnc(p_int number) return number is
    begin
        return trunc(p_int);
    end;
    explain plan for select id from t group by id;
    select * from table(dbms_xplan.display(null,null,'advanced'));
    explain plan for select test_fnc(id) from t group by test_fnc(id);
    select * from table(dbms_xplan.display(null,null,'advanced'));
    explain plan for select test_fnc(id) from (select id from t group by id);
    select * from table(dbms_xplan.display(null,null,'advanced'));Output:
    PLAN_TABLE_OUTPUT
    Plan hash value: 47235625
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   1 |  HASH GROUP BY     |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   2 |   TABLE ACCESS FULL| T    | 10000 | 30000 |   159   (1)| 00:00:02 |
    Query Block Name / Object Alias (identified by operation id):
       1 - SEL$1
       2 - SEL$1 / T@SEL$1
    Outline Data
      /*+
          BEGIN_OUTLINE_DATA
          FULL(@"SEL$1" "T"@"SEL$1")
          OUTLINE_LEAF(@"SEL$1")
          ALL_ROWS
          OPTIMIZER_FEATURES_ENABLE('10.2.0.4')
          IGNORE_OPTIM_EMBEDDED_HINTS
          END_OUTLINE_DATA
    Column Projection Information (identified by operation id):
       1 - (#keys=1) "ID"[NUMBER,22]
       2 - "ID"[NUMBER,22]
    34 rows selected.
    SQL>
    Explained.
    SQL>
    PLAN_TABLE_OUTPUT
    Plan hash value: 47235625
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   1 |  HASH GROUP BY     |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   2 |   TABLE ACCESS FULL| T    | 10000 | 30000 |   159   (1)| 00:00:02 |
    Query Block Name / Object Alias (identified by operation id):
       1 - SEL$1
       2 - SEL$1 / T@SEL$1
    Outline Data
      /*+
          BEGIN_OUTLINE_DATA
          FULL(@"SEL$1" "T"@"SEL$1")
          OUTLINE_LEAF(@"SEL$1")
          ALL_ROWS
          OPTIMIZER_FEATURES_ENABLE('10.2.0.4')
          IGNORE_OPTIM_EMBEDDED_HINTS
          END_OUTLINE_DATA
    Column Projection Information (identified by operation id):
       1 - (#keys=1) "TEST_FNC"("ID")[22]
       2 - "ID"[NUMBER,22]
    34 rows selected.
    SQL>
    Explained.
    SQL> select * from table(dbms_xplan.display(null,null,'advanced'));
    PLAN_TABLE_OUTPUT
    Plan hash value: 47235625
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   1 |  HASH GROUP BY     |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   2 |   TABLE ACCESS FULL| T    | 10000 | 30000 |   159   (1)| 00:00:02 |
    Query Block Name / Object Alias (identified by operation id):
       1 - SEL$F5BB74E1
       2 - SEL$F5BB74E1 / T@SEL$2
    Outline Data
      /*+
          BEGIN_OUTLINE_DATA
          FULL(@"SEL$F5BB74E1" "T"@"SEL$2")
          OUTLINE(@"SEL$2")
          OUTLINE(@"SEL$1")
          MERGE(@"SEL$2")
          OUTLINE_LEAF(@"SEL$F5BB74E1")
          ALL_ROWS
          OPTIMIZER_FEATURES_ENABLE('10.2.0.4')
          IGNORE_OPTIM_EMBEDDED_HINTS
          END_OUTLINE_DATA
    Column Projection Information (identified by operation id):
       1 - (#keys=1) "ID"[NUMBER,22]
       2 - "ID"[NUMBER,22]
    37 rows selected.

  • How do I create an undeclared namespace node with sql/xml?

    I have to interact with a .NET web service that is expecting to have an xml node with an undeclared namespace, i.e. <address xmlns=""> I figured that I could create this by using XMLATTRIBUTES ( '' AS "xmlns") but a null attribute will not be added to the attribute listing. This works fine for other xmlns entries that contain values. Without this undeclared namespace node, the web service reports an Internal SOAP failure message, so I have to include it. Do I have to resort to manually injecting this null attribute via DOM after I produce the xml? I'm using SQL/XML query generate the xml as a view which gives me the entire packet for this document/literal web service OTHER THAN this missing undeclared namespace element.
    Any tips/suggestions would be helpful! Thanks a bunch, and have a Happy Holiday Season.
    Eric

    You can use UTL_RAW package.
    First, convert string to raw with UTL_RAW.CAST_TO_RAW, then using UTL_RAW.CONVERT to convert raw to utf-8 and finally UTL_RAW.CAST_TO_VARCHAR to get utf-8 string.
    Regards

  • How to track the sql commands issued against database

    Hello, We are using an interface developed by oracle forms. Its giving some error while pressing an icon. I can not able to trace out from where it arises. This error is displayed by form developed by oracle forms. I dont have source code to track it. I would like to know , which SQL statement rises the error, so that I can update the oracle object and can able to solve the problem if I can able to find the exect SQL statment issued before the error was displayed. kindly help me . thanks.

    habfat wrote:
    Hello, We are using an interface developed by oracle forms. Its giving some error while pressing an icon. I can not able to trace out from where it arises. This error is displayed by form developed by oracle forms. I dont have source code to track it. I would like to know , which SQL statement rises the error, so that I can update the oracle object and can able to solve the problem if I can able to find the exect SQL statment issued before the error was displayed. kindly help me . thanks.Hmm, well kind of a silly but still, if you don't have source code of the form( you said so) so even if you would come to know what statement is raising the error, how would you go and edit it ? Did I miss some thing? And you asked for a sql statement ? How did you come to know that its a sql statement that is causing the error? And if that's actually a sql statement error, isn't it associated with a meaningful message ?
    Find the developer who coded the application, he would be the best person to track the error and tell you its resolution IMO.
    HTH
    Aman....

  • ?xml version = '1.0' encoding = 'ASCII'? pl/sql xml parser

    When ever I parse a document which has the
    <?xml version = '1.0' encoding = 'ASCII'?> tag as the first line hangs the pl/sql xml parser . If I remove the "encoding = 'ASCII'" from the file everything works fine ! What is the problem ?
    version 8.1.6 / plsql parser v2 / hpux 11x
    Here is the input file
    <?xml version = '1.0' encoding = 'ASCII'?>
    !--- This is a comment -->
    <person>
    <employee>
    <lastname>GHANTASALA</lastname>
    <firstname>SREE</firstname>
    <age>32</age>
    </employee>
    <employee>
    <lastname>TAMATAM</lastname>
    <firstname>SATISH</firstname>
    <age>30</age>
    </employee>
    </person>
    Here is my program
    declare
    p xmlparser.parser;
    doc xmldom.DOMDocument;
    dir varchar2(100) := '/apps/oracle/drugstore';
    errfile varchar2(30) := 'err.txt' ;
    inpfile varchar2(30) := 'person.xml';
    nl xmldom.DOMNodeList;
    len number;
    n xmldom.DOMNode;
    new_node xmldom.DOMNode;
    node_name varchar2(100);
    node_value varchar2(100);
    begin
    -- new parser
    p := xmlparser.newParser;
    -- Set some characteristics
    xmlparser.setValidationMode(p, FALSE);
    xmlparser.setErrorLog(p, dir&#0124; &#0124;'/'&#0124; &#0124; errfile );
    xmlparser.setBaseDir(p, dir);
    -- parse input file
    xmlparser.parse(p, dir&#0124; &#0124;'/'&#0124; &#0124;inpfile);
    -- get document
    doc := xmlparser.getDocument(p);
    -- get all elements
    nl := xmldom.getElementsByTagName(doc, '*');
    len := xmldom.getLength(nl);
    dbms_output.put_line('Length='&#0124; &#0124;len);
    -- loop through elements
    for i in 0..len-1 loop
    n := xmldom.item(nl, i);
    node_name := xmldom.getNodeName(n);
    -- get the text node associated with the element node
    n := xmldom.getFirstChild(n);
    if xmldom.getNodeType(n) = xmldom.TEXT_NODE then
    node_value := xmldom.getNodeValue(n);
    if node_name='lastname' then
    dbms_output.put_line('The value you are looking for is -->:'&#0124; &#0124;node_value);
    if node_value = 'GHANTASALA' then
    xmldom.setNodeValue(n,'TEST2');
    end if;
    end if;
    end if;
    end loop;
    new_node := xmldom.makeNode(doc);
    xmldom.writeToFile(new_node, dir &#0124; &#0124;'/'&#0124; &#0124;'mod.xml');
    end ;
    null

    The encoding header is actually generated by
    by the following piece of code in my pl/sql program .
    new_node := xmldom.makeNode(doc);
    xmldom.writeToFile(new_node, dir &#0124; &#0124;'/'&#0124; &#0124;'mod.xml');
    Since this is a document created by the pl/sql parser, I assume there is some meaning to it !
    Also why is it hanging ? PL/sql parser should tell me that it is not a valid string !

  • PL/SQL speed issues when using a variable

    I have a very strange issue that is causing problems.
    I am running Golden connecting to a 11g database.
    I created a procedure to insert records into a table based on a query. The source query includes variables that I have populated prior to the insert statement. The problem is that if I use the variable for one very specific where statement, the statement goes from running in less than 1 second, to running in 15 minutes. It gets even more strange though. Not only does a 2nd variable not cause any problems, the exact same variable in the same statement works fine.
    This procedure takes 15 minutes to run.
    declare
        v_start_period date;
        v_end_period date;
    begin
        select add_months(trunc(sysdate,'mm'), -1), trunc(sysdate,'mm')
        into v_start_period, v_end_period
        from dual;
        insert into RESULTS_TABLE
                (first_audit_date, last_audit_date,
                data_column1, data_column2, data_column3)
            select
                a.first_audit_date, a.last_audit_date,
                b.data_column1, b.data_column2, b.data_column3
            from
                SOURCE_TABLE_1 b,
                (select marker_id, min(action_time) as first_audit_date, max(action_time) as last_audit_date
                    from SOURCE_TABLE_2
                    where action_time >= v_start_period and action_time < v_end_period
                    group by marker_id) a
            where b.marker_id = a.marker_id
                and exists (select 1 from SOURCE_TABLE_2
                    where marker_id = b.marker_id
                    and action_time >= v_start_period and action_time < v_end_period
                    and action_type = 'XYZ');
        commit;
    end;This procedure runs in less than 1 second, yet returns the exact same results.
    declare
        v_start_period date;
        v_end_period date;
    begin
        select add_months(trunc(sysdate,'mm'), -1), trunc(sysdate,'mm')
        into v_start_period, v_end_period
        from dual;
        insert into RESULTS_TABLE
                (first_audit_date, last_audit_date,
                data_column1, data_column2, data_column3)
            select
                a.first_audit_date, a.last_audit_date,
                b.data_column1, b.data_column2, b.data_column3
            from
                SOURCE_TABLE_1 b,
                (select marker_id, min(action_time) as first_audit_date, max(action_time) as last_audit_date
                    from SOURCE_TABLE_2
                    where action_time >= v_start_period and action_time < trunc(sysdate,'mm')
                    group by marker_id) a
            where b.marker_id = a.marker_id
                and exists (select 1 from SOURCE_TABLE_2
                    where marker_id = b.marker_id
                    and action_time >= v_start_period and action_time < v_end_period
                    and action_type = 'XYZ');
        commit;
    end;The only difference between the two is where I replace the first v_end_period variable with trunc(sysdate,'mm').
    I've been googling for possible solutions and keep running into something called "parameter sniffing". It appears to be a SQL Server issue though, as I cannot find solutions for Oracle. I tried nesting the insert statement inside it's own procedure with new variables populated by the old variables, but nothing changed.
    Edited by: user_7000017 on Jan 8, 2013 9:45 AM
    Edited by: user_7000017 on Jan 8, 2013 9:52 AM Put the code in code tags.

    You are not describing procedures. You are listing anonymous PL/SQL blocks.
    As for the code - this approach to assigning PL/SQL variables are highly questionable. As the functions are native PL/SQL functions too, there is no need to parse and execute a SQL cursor, do context switching, in order to assign values to PL/SQL variables.
    This is wrong:
    select
        add_months(trunc(sysdate,'mm'), -1), trunc(sysdate,'mm')
        into v_start_period, v_end_period
    from dual;This is correct:
    v_start_period := add_months(trunc(sysdate,'mm'), -1);
    v_end_period := trunc(sysdate,'mm');Just as you would not use +"select 1 into plVariable from dual;+", instead of a standard variable assignment statement like +"plVariable := 1;"+.
    As for the performance/execution difference. Does not make sense. I suggest simplifying the code in order to isolate the problem. For example, take that in-line SQL (aliased as a in the main SQL) and create a testcase where it uses the function, versus a PL/SQL bind variable with the same data type and value as that returned by the function. Examine and compare the execution plans.
    Increase complexity (if no error) and repeat. Until the error is isolated.
    The 1st step in any troubleshooting, is IDENTIFYING the problem. Without knowing what the problem is, how can one fix it?

  • PL/SQL XML Parser demo

    i've downloaded the Pl/SQL XML parser demo - xslsample / domsample - followed the guide , etc but I'm getting ....
    BEGIN xslsample ('/export/home/oracle/plmx/sample','family.xml','iden.xsl','family.out','errors.txt'); END;
    ERROR at line 1:
    ORA-29516: Aurora assertion failure: Assertion failure at eox.c:187
    Uncaught exception Root of all Java exceptions:
    ORA-06512: at "PLMX.XMLPARSERCOVER", line 0
    ORA-06512: at "PLMX.XMLPARSER", line 57
    ORA-06512: at "PLMX.XSLSAMPLE", line 28
    ORA-06512: at line 1
    anybody seen this ??

    There is no such limit on our Parser for PL/SQL. Could you
    perhaps be using the PLXML Utilities? If you are you might try
    our PL/SQL Parser instead.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    Premal Mehta (guest) wrote:
    : Hi
    : I am using PL/SQL XML Parser to add XML data in database. I
    : am having trouble when using file sixe greater than 500KB?
    : What is the alternative? Can I do something to process
    larger
    : files?
    : Please Help, this is quite urgent.
    : Hoping for help,
    : Premal.
    null

  • How to tune the performance of Oracle SQL/XML query?

    Hi all,
    I am running Oracle 9i and like to run the following Oracle SQL/XML query. It takes about 3+ hour and still not finish. If I get rid all the XML stuffs it only take minutes to run. Does anybody know how to what's the reason of this slow and how to tune it?
    SELECT XMLElement("CUSTOMER",
    XMLForest(C_CUSTKEY "C_CUSTKEY", C_NAME "C_NAME", C_ADDRESS "C_ADDRESS", C_PHONE "C_PHONE", C_MKTSEGMENT "C_MKTSEGMENT", C_COMMENT "C_COMMENT"),
    (SELECT XMLAgg(XMLElement("ORDERS",
    XMLForest(O_ORDERKEY "O_ORDERKEY", O_CUSTKEY "O_CUSTKEY", O_ORDERSTATUS "O_ORDERSTATUS", O_ORDERPRIORITY "O_ORDERPRIORITY", O_CLERK "O_CLERK", O_COMMENT "O_COMMENT"),
    (SELECT XMLAgg(XMLElement("LINEITEM",
    XMLForest(L_ORDERKEY "L_ORDERKEY", L_RETURNFLAG "L_RETURNFLAG", L_LINESTATUS "L_LINESTATUS", L_SHIPINSTRUCT "L_SHIPINSTRUCT", L_SHIPMODE "L_SHIPMODE", L_COMMENT "L_COMMENT")
    FROM LINEITEM
    WHERE LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY)
    FROM ORDERS
    WHERE ORDERS.O_CUSTKEY = CUSTOMER.C_CUSTKEY)
    FROM CUSTOMER ;
    Thanks very much in advance for your time,
    Jinghao Liu

    ajallen wrote:
    Why not something more like
    SELECT *
    FROM fact1 l,
    FULL OUTER JOIN fact1 d
    ON l.company = d.company
    AND l.transactiontypeid = 1
    AND d.transactiontypeid = 2;
    Because this is not an equivalent of the original query.
    drop table t1 cascade constraints purge;
    drop table t2 cascade constraints purge;
    create table t1 as select rownum t1_id from dual connect by level <= 5;
    create table t2 as select rownum+2 t2_id from dual connect by level <= 5;
    select * from (select * from t1 where t1_id > 2) t1 full outer join t2 on (t1_id = t2_id);
    select * from t1 full outer join t2 on (t1_id = t2_id and t1_id > 2);
         T1_ID      T2_ID
             3          3
             4          4
             5          5
                        6
                        7
         T1_ID      T2_ID
             1
             2
             3          3
             4          4
             5          5
                        6
                        7

  • How to perf tune Oracle SQL/XML query?

    Hi all,
    I am using Oracle 9i and like to run the following Oracle SQL/XML query. It takes about 3+ hour and still not finish. If I get rid all the XML stuffs it only take minutes to run. Does anybody know how to what's the reason of this slow and how to tune it?
    SELECT XMLElement("CUSTOMER",
    XMLForest(C_CUSTKEY "C_CUSTKEY", C_NAME "C_NAME", C_ADDRESS "C_ADDRESS", C_PHONE "C_PHONE", C_MKTSEGMENT "C_MKTSEGMENT", C_COMMENT "C_COMMENT"),
    (SELECT XMLAgg(XMLElement("ORDERS",
    XMLForest(O_ORDERKEY "O_ORDERKEY", O_CUSTKEY "O_CUSTKEY", O_ORDERSTATUS "O_ORDERSTATUS", O_ORDERPRIORITY "O_ORDERPRIORITY", O_CLERK "O_CLERK", O_COMMENT "O_COMMENT"),
    (SELECT XMLAgg(XMLElement("LINEITEM",
    XMLForest(L_ORDERKEY "L_ORDERKEY", L_RETURNFLAG "L_RETURNFLAG", L_LINESTATUS "L_LINESTATUS", L_SHIPINSTRUCT "L_SHIPINSTRUCT", L_SHIPMODE "L_SHIPMODE", L_COMMENT "L_COMMENT")
    FROM LINEITEM
    WHERE LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY)
    FROM ORDERS
    WHERE ORDERS.O_CUSTKEY = CUSTOMER.C_CUSTKEY)
    FROM CUSTOMER ;
    Thanks very much in advance for your time,
    Jinghao Liu

    Please post this message at:
    Forums Home » Oracle Technology Network (OTN) » Products » Database » XML DB

  • Oracle 11g - External Table/SQL Developer Issue?

    Oracle 11g - External Table/SQL Developer Issue?
    ==============================
    I hope this is the right forum for this issue, if not let me, where to go.
    We are using Oracle 11g (11.2.0.1.0) on (Platform : solaris[tm] oe (64-bit)), Sql Developer 3.0.04
    We are trying to use oracle external table to load text files in .csv format. Here is our data look like.
    ======================
    Date1,date2,Political party,Name, ROLE
    20-Jan-66,22-Nov-69,Democratic,"John ", MMM
    22-Nov-70,20-Jan-71,Democratic,"John Jr.",MMM
    20-Jan-68,9-Aug-70,Republican,"Rick Ford Sr.", MMM
    9-Aug-72,20-Jan-75,Republican,Henry,MMM
    ------ ALL NULL -- record
    20-Jan-80,20-Jan-89,Democratic,"Donald Smith",MMM
    ======================
    Our Expernal table structures is as follows
    CREATE TABLE P_LOAD
    DATE1 VARCHAR2(10),
    DATE2 VARCHAR2(10),
    POL_PRTY VARCHAR2(30),
    P_NAME VARCHAR2(30),
    P_ROLE VARCHAR2(5)
    ORGANIZATION EXTERNAL
    (TYPE ORACLE_LOADER
    DEFAULT DIRECTORY P_EXT_TAB_D
    ACCESS PARAMETERS (
    RECORDS DELIMITED by NEWLINE
    SKIP 1
    FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' LDRTRIM
    REJECT ROWS WITH ALL NULL FIELDS
    MISSING FIELD VALUES ARE NULL
    DATE1 CHAR (10) Terminated by "," ,
    DATE2 CHAR (10) Terminated by "," ,
    POL_PRTY CHAR (30) Terminated by "," ,
    P_NAME CHAR (30) Terminated by "," OPTIONALLY ENCLOSED BY '"' ,
    P_ROLE CHAR (5) Terminated by ","
    LOCATION ('Input.dat')
    REJECT LIMIT UNLIMITED;
         It created successfully using SQL Developer
    Here is the issue.
    It is not loading the records, where fields are enclosed in '"' (Rec # 2,3,4,7)
    It is loading all NULL value record (Rec # 6)     
    *** If we remove the '"' from input data, it loads all records including all NULL records
    Log file has
    KUP-04021: field formatting error for field P_NAME
    KUP-04036: second enclosing delimiter not found
    KUP-04101: record 2 rejected in file ....
    Our questions
    Why did "REJECT ROWS WITH ALL NULL FIELDS" not working?
    Why did Terminated by "," OPTIONALLY ENCLOSED BY '"' not working?
    Any idea?
    Thanks in helping.

    I don't think this is a SQLDeveloper issue. You will get better answers in the Database - General or perhaps SQL and PL/SQL forums.

  • Re-Write the Node-DOM code with SQL-XML funtions

    Hi Friends,
    Could you please help in re-writing the below code using SQl-XML functions
    DECLARE
    l_domdoc dbms_xmldom.DOMDocument;
    l_xmltype XMLTYPE;
    l_root_node dbms_xmldom.DOMNode;
    l_departments_node dbms_xmldom.DOMNode;
    l_dept_element dbms_xmldom.DOMElement;
    l_dept_node dbms_xmldom.DOMNode;
    l_name_node dbms_xmldom.DOMNode;
    l_name_textnode dbms_xmldom.DOMNode;
    l_location_node dbms_xmldom.DOMNode;
    l_location_textnode dbms_xmldom.DOMNode;
    l_employees_node dbms_xmldom.DOMNode;
    l_emp_element dbms_xmldom.DOMElement;
    l_emp_node dbms_xmldom.DOMNode;
    l_emp_first_name_node dbms_xmldom.DOMNode;
    l_emp_first_name_textnode dbms_xmldom.DOMNode;
    l_emp_last_name_node dbms_xmldom.DOMNode;
    l_emp_last_name_textnode dbms_xmldom.DOMNode;
    BEGIN
    -- Create an empty XML document
    l_domdoc := dbms_xmldom.newDomDocument;
    -- Create a root node
    l_root_node := dbms_xmldom.makeNode(l_domdoc);
    -- Create a new node Departments and add it to the root node
    l_departments_node := dbms_xmldom.appendChild( l_root_node
    , dbms_xmldom.makeNode(dbms_xmldom.createElement(l_domdoc, 'Deptartments' ))
    FOR r_dept IN (SELECT dept.department_id
    , dept.department_name
    , loc.city
    FROM departments dept
    JOIN locations loc
    ON loc.location_id = dept.location_id
    WHERE dept.department_id IN (10,20)
    LOOP
    -- For each record, create a new Dept element with the Department ID as attribute.
    -- and add this new Dept element to the Departments node
    l_dept_element := dbms_xmldom.createElement(l_domdoc, 'Dept' );
    dbms_xmldom.setAttribute(l_dept_element, 'Deptno', r_dept.Department_Id );
    l_dept_node := dbms_xmldom.appendChild( l_departments_node
    , dbms_xmldom.makeNode(l_dept_element)
    -- Each Dept node will get a Name node which contains the department name as text
    l_name_node := dbms_xmldom.appendChild( l_dept_node
    , dbms_xmldom.makeNode(dbms_xmldom.createElement(l_domdoc, 'Name' ))
    l_name_textnode := dbms_xmldom.appendChild( l_name_node
    , dbms_xmldom.makeNode(dbms_xmldom.createTextNode(l_domdoc, r_dept.department_name ))
    -- Each Dept node will aslo get a Location node which contains the location(city) as text
    l_location_node := dbms_xmldom.appendChild( l_dept_node
    , dbms_xmldom.makeNode(dbms_xmldom.createElement(l_domdoc, 'Location' ))
    l_location_textnode := dbms_xmldom.appendChild( l_location_node
    , dbms_xmldom.makeNode(dbms_xmldom.createTextNode(l_domdoc, r_dept.city ))
    -- For each department, add an Employees node
    l_employees_node := dbms_xmldom.appendChild( l_dept_node
    , dbms_xmldom.makeNode(dbms_xmldom.createElement(l_domdoc, 'Employees' ))
    FOR r_emp IN (SELECT employee_id
    , first_name
    , last_name
    FROM employees
    WHERE department_id = r_dept.department_id
    LOOP
    -- For each record, create a new Emp element with the Employee ID as attribute.
    -- and add this new Emp element to the Employees node
    l_emp_element := dbms_xmldom.createElement(l_domdoc, 'Emp' );
    dbms_xmldom.setAttribute(l_emp_element, 'empid', r_emp.employee_id );
    l_emp_node := dbms_xmldom.appendChild( l_employees_node
    , dbms_xmldom.makeNode(l_emp_element)
    -- Each emp node will get a First name and Last name node which contains the first name and last name as text
    l_emp_first_name_node := dbms_xmldom.appendChild( l_emp_node
    , dbms_xmldom.makeNode(dbms_xmldom.createElement(l_domdoc, 'FirstName' ))
    l_emp_first_name_textnode := dbms_xmldom.appendChild( l_emp_first_name_node
    , dbms_xmldom.makeNode(dbms_xmldom.createTextNode(l_domdoc, r_emp.first_name ))
    l_emp_last_name_node := dbms_xmldom.appendChild( l_emp_node
    , dbms_xmldom.makeNode(dbms_xmldom.createElement(l_domdoc, 'LastName' ))
    l_emp_last_name_textnode := dbms_xmldom.appendChild( l_emp_last_name_node
    , dbms_xmldom.makeNode(dbms_xmldom.createTextNode(l_domdoc, r_emp.last_name ))
    END LOOP;
      END LOOP;
    l_xmltype := dbms_xmldom.getXmlType(l_domdoc);
    dbms_xmldom.freeDocument(l_domdoc);
    dbms_output.put_line(l_xmltype.getClobVal);
    END;
    thanks and regards,
    Arun Thomas T

    It's as easy as this :
    SQL> select xmlserialize(document
      2           xmlelement("Departments"
      3           , xmlagg(
      4               xmlelement("Dept"
      5               , xmlattributes(d.department_id as "Deptno")
      6               , xmlforest(
      7                   d.department_name as "Name"
      8                 , l.city as "Location"
      9                 )
    10               , xmlelement("Employees"
    11                 , (
    12                     select xmlagg(
    13                              xmlelement("Emp"
    14                              , xmlattributes(e.employee_id as "empid")
    15                              , xmlforest(
    16                                  e.first_name as "FirstName"
    17                                , e.last_name as "LastName"
    18                                )
    19                              )
    20                            )
    21                     from hr.employees e
    22                     where e.department_id = d.department_id
    23                   )
    24                 )
    25               )
    26             )
    27           )
    28           indent
    29         )
    30  from hr.departments d
    31       join hr.locations l on l.location_id = d.location_id
    32  where d.department_id in (10,20) ;
    XMLSERIALIZE(DOCUMENTXMLELEMEN
    <Departments>
      <Dept Deptno="10">
        <Name>Administration</Name>
        <Location>Seattle</Location>
        <Employees>
          <Emp empid="200">
            <FirstName>Jennifer</FirstName>
            <LastName>Whalen</LastName>
          </Emp>
        </Employees>
      </Dept>
      <Dept Deptno="20">
        <Name>Marketing</Name>
        <Location>Toronto</Location>
        <Employees>
          <Emp empid="201">
            <FirstName>Michael</FirstName>
            <LastName>Hartstein</LastName>
          </Emp>
          <Emp empid="202">
            <FirstName>Pat</FirstName>
            <LastName>Fay</LastName>
          </Emp>
        </Employees>
      </Dept>
    </Departments>

Maybe you are looking for

  • Mac Mini (Late 2014) not recognizing SSD OCZ Vertex 2

    Hello community, After days of tests and readings, I turn to you to seek for advice. Here is my problem: I am trying to upgrade a new Mac Mini (Late 2014 model) from it's original mechanical HDD to a Vertex 2 SSD I have been using for a few years wit

  • Error processing request in sax parser  No 'action' attribute found in XML

    Hi All,         I am doing a FILE to JDBC Scenario.  I just want to send a data from file to Sql Db table. For this I have written a stored procedure to insert the row in a table. This is the message mapping for FILE to JDBC …. Sender                

  • "photo cart" & MobileMe (iWeb)

    i know this is more of a MobileMe ? i posted it there too, but you here w/the iWeb area are soo handy and smart so i tried to iChat w/a MobileMe expert but he didn't know squat! i am a photographer and i really need a "photo cart" because my current

  • Vendor evaluation - Automatic scoring method

    Dear All, With auto evaluation of vendors, I get some vendors without having any score in some main criteria i.e. Price, Quality and Delivery. What may be the reasons?  How we can cross check system alloted scores? Regards Manoj

  • InDesign CS4 Debug not working on Windows

    Dear All, Two days back I purchased Bronze ASN memebership. This is the first time when I am trying debug version of InDesign. I have installed InDesign CS4 Debug on both Mac & Windows. On Mac it is working fine, but on windows it is not working. Deb