Pl/sql xml help

i am executing the following pl/sql block an getting error
DECLARE
ERROR at line 1:
ORA-01405: fetched column value is NULL
DECLARE
l_bfile BFILE;
l_clob CLOB;
l_parser dbms_xmlparser.Parser;
l_doc dbms_xmldom.DOMDocument;
l_nl dbms_xmldom.DOMNodeList;
l_n dbms_xmldom.DOMNode;
l_temp VARCHAR2(1000);
TYPE tab_type IS TABLE OF profile%ROWTYPE;
t_tab tab_type := tab_type();
p_open_close boolean default false;
BEGIN
dbms_output.put_line('opening xml file');
l_bfile := BFileName('/opt/sqlutil', 'test.xml');
dbms_output.put_line('xml file opened');
dbms_lob.createtemporary(l_clob, cache=>FALSE);
dbms_output.put_line('created temp');
if not p_open_close then
dbms_output.put_line('file closed now opening');
dbms_lob.fileopen(l_bfile, dbms_lob.lob_readonly);
end if;
dbms_output.put_line('file opened');
dbms_lob.loadFromFile(dest_lob => l_clob,
src_lob => l_bfile,
amount => dbms_lob.getLength(l_bfile));
dbms_output.put_line('file loaded');
dbms_lob.close(l_bfile);
dbms_output.put_line('file closed');
-- make sure implicit date conversions are performed correctly
-- dbms_session.set_nls('NLS_DATE_FORMAT','''DD-MON-YYYY''');
-- Create a parser.
l_parser := dbms_xmlparser.newParser;
-- Parse the document and create a new DOM document.
dbms_xmlparser.parseClob(l_parser, l_clob);
l_doc := dbms_xmlparser.getDocument(l_parser);
-- Free resources associated with the CLOB and Parser now they are no longer needed.
dbms_lob.freetemporary(l_clob);
dbms_xmlparser.freeParser(l_parser);
-- Get a list of all the EMP nodes in the document using the XPATH syntax.
l_nl := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'/Member');
-- Loop through the list and create a new record in a tble collection
-- for each Member record.
dbms_output.put_line('Length of xml='||dbms_xmldom.getLength(l_nl));
/* FOR cur_emp IN 0 .. dbms_xmldom.getLength(l_nl) - 1 LOOP
l_n := dbms_xmldom.item(l_nl, cur_emp);
dbms_output.put_line('got xml node');
t_tab.extend;
-- Use XPATH syntax to assign values to he elements of the collection.
dbms_xslprocessor.valueOf(l_n,'USI/text()',t_tab(t_tab.last).ep_ID );*/
/* dbms_xslprocessor.valueOf(l_n,'ENAME/text()',t_tab(t_tab.last).ename);
dbms_xslprocessor.valueOf(l_n,'JOB/text()',t_tab(t_tab.last).job);
dbms_xslprocessor.valueOf(l_n,'MGR/text()',t_tab(t_tab.last).mgr);
dbms_xslprocessor.valueOf(l_n,'HIREDATE/text()',t_tab(t_tab.last).hiredate);
dbms_xslprocessor.valueOf(l_n,'SAL/text()',t_tab(t_tab.last).sal);
dbms_xslprocessor.valueOf(l_n,'COMM/text()',t_tab(t_tab.last).comm);
dbms_xslprocessor.valueOf(l_n,'DEPTNO/text()',t_tab(t_tab.last).deptno);*/
-- END LOOP;
-- Insert data into the real EMP table from the table collection.
-- Form better performance multiple collections should be used to allow
-- bulk binding using the FORALL construct but this would make the code
-- too long-winded for this example.
/* FOR cur_emp IN t_tab.first .. t_tab.last LOOP
dbms_output.put_line(t_tab(cur_emp).EBCP_USI_ID);*/
/*INSERT INTO emp
(empno,
ename,
job,
mgr,
hiredate,
sal,
comm,
deptno)
VALUES
(t_tab(cur_emp).empno,
t_tab(cur_emp).ename,
t_tab(cur_emp).job,
t_tab(cur_emp).mgr,
t_tab(cur_emp).hiredate,
t_tab(cur_emp).sal,
t_tab(cur_emp).comm,
t_tab(cur_emp).deptno);*/
--END LOOP;
-- COMMIT;
-- Free any resources associated with the document now it
-- is no longer needed.
dbms_xmldom.freeDocument(l_doc);
EXCEPTION
WHEN OTHERS THEN
dbms_lob.freetemporary(l_clob);
dbms_xmlparser.freeParser(l_parser);
dbms_xmldom.freeDocument(l_doc);
END;
/

You have an exception section at the end that should catch all exceptions and you are not re-rasing the error from that exception block. How is the error being raised?
EXCEPTION
    WHEN OTHERS THEN
        dbms_lob.freetemporary(l_clob);
        dbms_xmlparser.freeParser(l_parser);
        dbms_xmldom.freeDocument(l_doc);
END;?
In any case, remove all exception handling and run it again. note the line numbers in the code that the error message displays and look at that line to see what might be wrong.

Similar Messages

  • Oracle AS connect to MS SQL server - help please.

    hi there
    can anyone tell or show me how to connect Oracle app server to MS sql server? thanks

    Hi Tom,
    For stand-alone OC4J (any version), you need to add an appropriate entry to the "data-sources.xml" file (in the "j2ee/home/config" subdirectory) and put the JDBC driver file(s) into the "j2ee/home/lib" subdirectory. On my OC4J 9.0.3 distribution (on my Windows XP machine), there already is a "ms-sql.xml" file in the "j2ee/home/config/database-schemas" subdirectory. If you don't have one, then you may need to create one, or if you do already have one, you may need to modify it. More information can be found at these Web sites:
    http://www.orionserver.com
    http://www.orionsupport.com
    http://www.atlassian.com
    http://www.elephantwalker.com
    Hope this helps you.
    Good Luck,
    Avi.

  • 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

  • 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

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

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

  • Creating optional elements using SQL / XML functions

    Hi,
    I am struggling with some SQL / XML functionality in order to create some optional elements in a XMLType.
    I have one table with data to be generated into an XML document. The table looks like this (only the attributes related to the problem are shown):
    msg_id (pk)
    geslacht_hoofdverzekerde
    geboortedatum_hoofdverzekerde
    geslacht_medeverzekerde
    geboortedatum_medeverzekerde
    I have to create an XML document that looks like this:
    <ber:rekenparameters>
    <ber:verzekerde>
    <ber:codeRelatierol>HVZ</ber:codeRelatierol>
    <ber:geslacht>M</ber:geslacht>
    <ber:datumGeboorte>01-01-1960</ber:datumGeboorte>
    </ber:verzekerde>
    <ber:verzekerde>
    <ber:codeRelatierol>MVZ</ber:codeRelatierol>
    <ber:geslacht>V</ber:geslacht>
    <ber:datumGeboorte>01-01-1961</ber:datumGeboorte>
    </ber:verzekerde>
    </ber:rekenparameters>
    Where <ber:codeRelatierol> is hard coded: i.c. of hoofverzekerde 'HVZ' in case of medeverzekerde 'MVZ'.
    Geslacht en datumGeboorte are taken form the table.
    The element <ber:verzekerde> is obligatiry for hoofdverzekerde but optional for medeverzekerde: only in case geslacht_medeverzekerde and geboortedatum_medeverzekerde are not null this 2nd <ber:verzekerde> element has to be added.
    I created the next SQL (I skipped some stuff in order to focus on the problem):
    CREATE OR REPLACE
    VIEW dps_v_berekening_berichten
    AS
    SELECT msg_id as msg_id
    , XMLElement( "ber:berekening"
    , XMLAttributes( 'http://www.w3.org/2001/XMLSchema-instance' AS "xmlns:xsi"
    , 'http://www.mycompany.nl/berekenen' AS "xmlns:ber"
    , 'http://www.mycompany.nl/berekenen http://www.mycompany.nl/berekenen/berekening.xsd' AS "xsi:schemaLocation"
    , XMLElement( "ber:nummerRekenRegel"
    , XMLAttributes( 'http://www.mycompany.nl/berekenen' AS "xmlns:ber" )
    , 1
    , XMLElement( "ber:rekenparameters"
    , XMLAttributes( 'http://www.mycompany.nl/berekenen' AS "xmlns:ber" )
    , XMLElement( "ber:codeEvolutie" ) -- Empty
    , XMLElement( "ber:verzekerde"
    , XMLForest ( 'HVZ' AS "ber:codeRelatierol"
    , xoa.geslacht_hoofdverzekerde AS "ber:geslacht"
    , xoa.geboortedatum_hoofdverzekerde AS "ber:datumGeboorte"
    , XMLElement( "ber:verzekerde"
    , XMLForest ( 'MVZ' AS "ber:codeRelatierol"
    , xoa.geslacht_medeverzekerde AS "ber:geslacht"
    , xoa.geboortedatum_medeverzekerde AS "ber:datumGeboorte"
    -- Some more elements.
    ) AS bericht
    FROM DST_UP1_XML_OUTDATA xoa
    The problem is that the XMLForest always creates an <ber:verzekerde> element for medeverzekerde. I tried to create an inline view with just the "vezekerde"attributes and conditionally joining this inline view with the dst_up1_xml_outdata table. That didn't solve my problem. Because in case of a medeverzekerde available it returned two XML documenst: one that included the hoofdverzekerde and one that included the medeverzekerde. And obviously that's not what I want.
    I imagine I have to juggle with some of these SQL / XML functions although I cannot put the finger on the exact differences between some of these (XMLElement, XMLForest, XMLAgg, XMLSequence). The examples shown in de XML DB Developer's Guide don't seem to adress my problem.
    Help !

    Hi, are you talking about this part that you don't want to be there? I am not so clear about your requirements.
    XMLElement( "ber:verzekerde"
    , XMLForest ( 'MVZ' AS "ber:codeRelatierol"
    , xoa.geslacht_medeverzekerde AS "ber:geslacht"
    , xoa.geboortedatum_medeverzekerde AS "ber:datumGeboorte"
    If you want to control certain subelements so they don't appear, do not use xmlforest. Use xmlelement instead so it is easier to control it using case when. Mark (of Oracle, he should be here soon since OOW is over) showed me this technique and it helps tremendously, because oftentimes XDB will return an empty tag even though your consumers don't like it!
    try something like this,
    (case when xoa.geboortedatum_medeverzekerde = 'MVZ' then
    xmlelement("ber:verzekerde",
    xmlelement("What you want", colname),
    xmlelement("ber:codeRelatierol", 'MVZ'),
    (case when colname is not null or = some other value then
    xmlelement("Rest", colname))
    end)
    end),
    You may have to twig some details there. But the key is to use the case when construct to get rid of unwanted elements or empty elements. So you should only have the elements if you have a value of 'MVZ'. Hope this helps.
    Ben

  • Sql/xml -  no namespace

    Hi
    I get a "LPX-00234: namespace prefix "def" is not declared" when i run the SQL/XML code below. It works fine when i run it without the Extract() function. I am using 9.2.0.6.0.
    any help is much appreciated. i am running this directly against the database and I have no namespace set up.
    select xmlelement(name "ItemDef",
    XMLAttributes (a.oid as "OID",a.name as "df.Name"),NULL).extract('/*').getclobval()
    FROM xmlview a

    Please ignore i am a fool... declared namespace def: in code, so need to declare a def namespace in code. Used workaround
    SELECT xmlelement("links", xmlattributes('link1' AS "xmlns:def",'link2' AS "xmlns:xlink"),
    rest of code
    works now
    cheers

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

  • ?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 !

  • 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

  • SQL*Plus Help

    Hi! Does anyone know where i can download SQL*Plus Help? I need to get info on select syntax, sql built-in functions, etc..
    Thanks!

    hi
    you can proceed like this :
    go to the OTN
    the click on products.
    null

  • Can I use SQL/XML feature on EVERY Oracle DB?

    I appreciate the SQL/XML as described here:
    http://www.oracle.com/technology/oramag/oracle/03-may/o33xml.html
    But I wonder if I can use these commands on EVERY Oracle DB.
    Do I have to prepare/setup an existing DB in any way for receiving such SQL/XML commands ? Or do I have to enable this feature/install an Add-On?
    Can I use this feature even with the Express Editions ?
    Peter

    SQL/XML appears in 9.2.x and later. Not all of the operators in the current (11g) product are available in earlier releases. Please check the SQL reference guide for a particular version. However that article is quite old so it probably only refers to the ones in 9.2.x

  • Sql/xml - powerful tool for complex reports

    I just want to share euphoria...
    HTMLDB itself provides powerful ways how to control the design of the page - various types of regions, page types, templates...
    Nevertheless sometimes you need even more precise control over the content and format of the displayed page. The combination of SQL/XML and HTMLDB solves it in very elegant way.
    - create page with common SQL report region.
    - prepare the SELECT gathering the data to be displayed
    - prepare another SELECT using SQL/XML functions adding HTML formating tags upon the first select.
    Example:
    select
    XMLTYPE.getStringVal(
    XMLElement("table",
    XMLAttributes('5' as cellpadding),
    XMLConcat(
    XMLElement("tr",
    XMLElement("td",
    XMLAttributes('left' as align, 'top' as valign),
    XMLElement("a",
    XMLAttributes(provider_url as href),
    XMLElement("img",XMLAttributes(provider_icon as src, provider_name as alt, provider_name as title))
    XMLElement("td",
    XMLAttributes('left' as align, 'top' as valign, '150' as width),
    XMLElement("a",
    XMLAttributes(event_url as href),
    XMLElement("div",XMLAttributes('font-weight:bold; font-style:normal; font-size:10px; ' as style), event_name_part2)
    XMLElement("div",XMLAttributes('font-weight:normal; font-style:normal; font-size:10px; ' as style), event_name_part1)
    XMLElement("td",
    XMLAttributes('right' as align, 'top' as valign),
    XMLElement("div",
    XMLElement("a",
    XMLAttributes( edit_url as href),
    XMLElement("img",
    XMLAttributes( '#IMAGE_PREFIX#ed-item.gif' as src, '14' as width, '14' as height, 'Editovat &#269;lánek/po&#345;ad' as alt, 'Editovat &#269;lánek/po&#345;ad' as title)
    XMLElement("div",
    XMLElement("a",
    XMLAttributes( delete_url as href),
    XMLElement("img",
    XMLAttributes( '#IMAGE_PREFIX#wastebasket.gif' as src, '16' as width, '16' as height, 'Smazat &#269;lánek/po&#345;ad' as alt, 'Smazat &#269;lánek/po&#345;ad' as title)
    ) as event_description
    from (select
    case
    when EVENT_PROVIDER_TYPE='Magazine' then set_1 || ' ' || set_2 || ' ' || set_3 || ' ' || set_4
    when EVENT_PROVIDER_TYPE='Radio' then set_1 || ' ' || set_2 || ' ' || set_3 || ' ' || set_4
    when EVENT_PROVIDER_TYPE='Author' then set_2
    end as event_name_part1,
    case
    when EVENT_PROVIDER_TYPE='Magazine' then set_5 || ' ' || set_6
    when EVENT_PROVIDER_TYPE='Radio' then set_5 || ' ' || set_6
    when EVENT_PROVIDER_TYPE='Author' then set_1
    end as event_name_part2,
    events.url as event_url,
    my_events.issue_date,
    providers.icon_path as provider_icon,
    providers.provider_name,
    case
    when substr(upper(providers.www_address),1,7)<>'HTTP://'
    then 'http://' || providers.www_address
    else providers.www_address
    end as provider_url,
    'f?p=' || v('APP_ID') || ':2:' || v('SESSION') || '::NO:16:P2_EVENT_ID,P2_EVENT_NAME:' || events.event_id || ',' || events.event_name as delete_url,
    'f?p=' || v('APP_ID') || ':35:' || v('SESSION') || '::NO:35:P35_SELECTED_EVENT_ID,P35_SELECTED_EVENT_NAME:' || events.event_id || ',' || events.event_name as edit_url
    from my_events
    join events on my_events.event_id=events.event_id
    join providers on EVENTS.PROVIDER_ID= PROVIDERS.PROVIDER_ID
    where my_events.user_id=:IAL_USER_ID
    order by my_events.issue_date desc)
    P.S. It's cool to use XMLAGG function in combination with GROUP BY clause - it enables you to easily display list of strings as a single filed on the formular....

    You will be able to use our XSL Processor to format into HTML or
    CSV once it is released next month. Adobe is sponsoring a
    context for a PDF engine for XML.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    Karl Reitschuster (guest) wrote:
    : We are developing an IntranetApplication with Oracle Webserver
    : and Oracle DB.
    : Reports should be generated in HTML or PDF or CSV.
    : IS there any tool which can generate these formats on XML-Base.
    : How do you generate your documentation which is both in PDF
    and
    : HTML?
    : For any Tips : thank you
    null

Maybe you are looking for