DBMS_XMLDOM.WRITETOFILE errors

C'mon then chaps (and chapesses)...
I've had DBMS_XMLDOM.WRITETOFILE working before but for some reason I just can't seem to get it to work again. (Using Oracle 10g R2)
What am I doing wrong. It's bound to be something right in front of me, but I just can't see it.
create or replace directory utl_data as 'C:\';
declare
  xd  DBMS_XMLDOM.DOMDocument;
  xt  XMLTYPE;
  CURSOR cur_xml IS
    select xmlelement("fred", 'fred') from dual;
begin
  OPEN cur_xml;
  FETCH cur_xml INTO xt;
  CLOSE cur_xml;
  xd := DBMS_XMLDOM.NewDOMDocument(xt);
  DBMS_XMLDOM.WRITETOFILE(xd, 'C:\FRED.XML');
end;
ORA-29280: invalid directory path
ORA-06512: at "SYS.UTL_FILE", line 33
ORA-06512: at "SYS.UTL_FILE", line 436
ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 217
ORA-29280: invalid directory path
ORA-29280: invalid directory path
ORA-06512: at "XDB.DBMS_XMLDOM", line 4416
ORA-06512: at line 12

Well that's very nice of you to answer my thread after a year, but I already know about using directory objects now.
I'm not quite sure what you are trying to show with you examples, but good luck to you anyway.

Similar Messages

  • DBMS_XMLDOM.WRITETOFILE

    Hi,
    I am creating a PL/SQL that should read from an XML file in XML DB Repository, create an XML file out of it.
    The lines I have in PL/SQL to create the XML file are:
    v_domdoc DBMS_XMLDOM.DOMDOCUMENT;
    v_domelement DBMS_XMLDOM.DOMELEMENT;
    v_domnode DBMS_XMLDOM.DOMNODE;
    v_domdoc := DBMS_XMLDOM.NEWDOMDOCUMENT();
    l_string := '/PUBLIC/OUT/AC.XML';
    DBMS_XMLDOM.WRITETOFILE(v_domnode, l_string);
    When I run the PL/SQL, I get the following error at WRITETOFILE:
    ORA-29280: invalid directory path
    ORA-06512: at "SYS.UTL_FILE", line 33
    ORA-06512: at "SYS.UTL_FILE", line 436
    ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 217
    ORA-29280: invalid directory path
    ORA-29280: invalid directory path
    What must I do in order to create the file successfully? By the way, '/PUBLIC/OUT' folder exists and AC.XML file does not exist.
    Thanks in advance
    Bharathan

    Sorry, I must have added these details in the first place.
    Yes, I do have read/write access at OS (Windows Vista Home Premium). I am trying to create the file in XML DB Repository.
    Following are the DB details:
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
    PL/SQL Release 10.2.0.3.0 - Production
    CORE     10.2.0.3.0     Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    I am using SQL*Developer to develop the PL/SQL. Please bear with me if I am not providing you enough details. Appreciate your help coming my way.
    Regards
    Bharathan

  • Writetofile error -- SYS.UTL_FILE

    I get below error when I use "dbms_xmldom.writetofile(doc,'output.xml')"
    ORA-04067: not executed, package body "SYS.UTL_FILE" does not exist
    Is this because the read-from and write-to directories in the initialization.ora file hasn't been specified? Thanks.

    Yes, and permissions to use UTL_FILE have been tightened up.

  • Reg :DBMS_XMLDOM.DOMDocument Error

    Hi all,
    I tried to create xml document in the C Drive .
    I Created Directory like :
    create or replace directory ctemp1 as 'C:\';
    GRANT ALL ON DIRECTORY ctemp1 to public;
    grant read,write on directory ctemp1 to public;
    The code is :
    DECLARE
    doc DBMS_XMLDOM.DOMDocument;
    xdata XMLTYPE;
    cursor XMLCUR is select SYS_XMLGEN(XMLAGG(XMLELEMENT("EMPNO", ename))) FROM EMP;
    Cursor xmlCurdate is
    select SYS_XMLGen(
    XMLELEMENT(NAME "UTIMEID",
    XMLATTRIBUTES (to_char((sysdate - 1),'yyyymmdd') as "uid",
    to_char((sysdate - 1),'mm/dd/yyyy (') || rtrim(to_char((sysdate - 1),'Day')) || ')' as "uiddesc")),
    sys.xmlgenformatType.createFormat('UPDATED-XML') ) from dual;
    BEGIN
    OPEN xmlcur;
    FETCH xmlcur INTO xdata;
    CLOSE xmlcur;
    doc := DBMS_XMLDOM.NewDOMDocument(xdata);
    DBMS_XMLDOM.WRITETOFILE(doc, 'ctemp1'||'\'||'alert.xml');
    OPEN xmlcurdate;
    FETCH xmlcurdate INTO xdata;
    CLOSE xmlcurdate;
    doc := DBMS_XMLDOM.NewDOMDocument(xdata);
    DBMS_XMLDOM.WRITETOFILE(doc, 'ctemp1'||'\'||'updated.xml');
    END;
    Am Getting the Error like :
    Error starting at line 8 in command:
    DECLARE
    doc DBMS_XMLDOM.DOMDocument;
    xdata XMLTYPE;
    cursor XMLCUR is select SYS_XMLGEN(XMLAGG(XMLELEMENT("EMPNO", ename))) FROM EMP;
    Cursor xmlCurdate is
    select SYS_XMLGen(
    XMLELEMENT(NAME "UTIMEID",
    XMLATTRIBUTES (to_char((sysdate - 1),'yyyymmdd') as "uid",
    to_char((sysdate - 1),'mm/dd/yyyy (') || rtrim(to_char((sysdate - 1),'Day')) || ')' as "uiddesc")),
    sys.xmlgenformatType.createFormat('UPDATED-XML') ) from dual;
    BEGIN
    OPEN xmlcur;
    FETCH xmlcur INTO xdata;
    CLOSE xmlcur;
    doc := DBMS_XMLDOM.NewDOMDocument(xdata);
    DBMS_XMLDOM.WRITETOFILE(doc, 'ctemp1'||'\'||'alert.xml');
    OPEN xmlcurdate;
    FETCH xmlcurdate INTO xdata;
    CLOSE xmlcurdate;
    doc := DBMS_XMLDOM.NewDOMDocument(xdata);
    DBMS_XMLDOM.WRITETOFILE(doc, 'ctemp1'||'\'||'updated.xml');
    END;
    Error report:
    ORA-29280: invalid directory path
    ORA-06512: at "SYS.UTL_FILE", line 33
    ORA-06512: at "SYS.UTL_FILE", line 436
    ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 217
    ORA-29280: invalid directory path
    ORA-29280: invalid directory path
    ORA-06512: at "XDB.DBMS_XMLDOM", line 4416
    ORA-06512: at line 16
    29280. 00000 - "invalid directory path"
    *Cause:    A corresponding directory object does not exist.
    *Action:   Correct the directory object parameter, or create a corresponding
    directory object with the CREATE DIRECTORY command.
    Please help on this .
    Thanks in advence .

    When you create objects on the database (tables, views, directories etc.) then by default they are stored in the data dictionary in UPPER case (unless you surround the name with double quotes which is poor practice).
    So, in your DBMS_XMLDOM.WRITETOFILE call you need to specify the directory name in UPPER case...
    DBMS_XMLDOM.WRITETOFILE(doc, 'CTEMP1'||...... simple as that. ;)

  • DBMS_XMLDOM.WRITETOFILE overloading

    Hello all. Quick question. I'm running into memory issues when creating my xml file using the DBMS_XMLDOM oracle 9i package. I'd like to write out the file initially and then append to it using DBMS_XMLDOM.WRITETOFILE throughout my program. Similar to "open_mode" using utl_file.fopen.
    Is this possible?

    In your example, how is the marco.xml file not getting written over each time with the next iteration of rc? Once you exit the loop, is that when the doc element is freed. Prior to that does the writetofile simply keep appending?
    Here is a sample piece of my code
    declare
       doc dbms_xmldom.DOMDocument;
       main_node dbms_xmldom.DOMNode;
       root_node dbms_xmldom.DOMNode;
       incident_node dbms_xmldom.DOMNode;
       item_node dbms_xmldom.DOMNode;
       root_elmt dbms_xmldom.DOMElement;
       item_elmt dbms_xmldom.DOMElement;
       item_text dbms_xmldom.DOMText;
       v_clob      CLOB := 'a';
       v_xml VARCHAR2(32767);
       output utl_file.file_type;
    begin
       -- get document
        doc := dbms_xmldom.newDOMDocument;
        -- create root element
        main_node := dbms_xmldom.makeNode(doc);
        root_elmt := dbms_xmldom.createElement(doc, 'Incidents');   
        dbms_xmldom.setAttribute(root_elmt, 'xmlns','http://www.claimsuite.com'); 
        dbms_xmldom.setAttribute(root_elmt, 'xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
        dbms_xmldom.setAttribute(root_elmt, 'xsi:schemaLocation', 'http://www.claimsuite.com ClaimsuiteShellUS.xsd');
        root_node := dbms_xmldom.appendChild(main_node, dbms_xmldom.makeNode(root_elmt)); 
       for i in 1 .. 2 loop
          item_elmt := dbms_xmldom.createElement(doc, 'Incident');
          incident_node := dbms_xmldom.appendChild(root_node, dbms_xmldom.makeNode(item_elmt));
          --CrawfordHandlingOfficeReference
          item_elmt := dbms_xmldom.createElement(doc, 'HandlingOfficeReference');     
          item_node := dbms_xmldom.appendChild(incident_node, dbms_xmldom.makeNode(item_elmt));
          item_text := dbms_xmldom.createTextNode(doc, 'HandlingOfficeRef');
          item_node := dbms_xmldom.appendChild(item_node, dbms_xmldom.makeNode(item_text));
       end loop;
       -- instead of writing to file, it writes to clob 
       dbms_xmldom.writeToFile(doc, 'IO_DIR_SHL_RSG/test.xml','ISO-8859-1');
       -- free resources
       dbms_xmldom.freeDocument(doc);
    end;Instead of having
    dbms_xmldom.writeToFile(doc, 'IO_DIR_SHL_RSG/test.xml','ISO-8859-1');at the end, I'd like to continuously append to the test.xml file instead of storing the huge dbms_xmldom.DOMDocument in memory and then writing it out at the end.

  • How to handle dbms_xmldom with no data values.(no_data_found error in dom)

    hi,
    i have below block,
    DECLARE
    doc dbms_xmldom.DOMDocument;
    node dbms_xmldom.DOMNode;
    elem dbms_xmldom.DOMElement;
    cur_node dbms_xmldom.DOMNode;
    root_elem_data dbms_xmldom.DOMElement;
    root_elem_tab dbms_xmldom.DOMElement;
    root_node_data dbms_xmldom.DOMNode;
    mode_elmn dbms_xmldom.DOMElement;
    mode_node dbms_xmldom.DOMNode;
    mode_text dbms_xmldom.DOMText;
    doc1 DBMS_XMLDOM.DOMDOCUMENT;
    root_node_data1 DBMS_XMLDOM.DOMNODE;
    child_document DBMS_XMLDOM.DOMDOCUMENT;
    child_rootnode DBMS_XMLDOM.DOMNODE;
    V_CLOB CLOB;
    v_doc CLOB;
    v_EMP CLOB;
    v_output_filename VARCHAR2(300) := 'SPOOL_DIR/'||'EMP_XML_FILE.xml';
    l_xmltype XMLTYPE;
    BEGIN
    doc := dbms_xmldom.newDOMDocument;
    node := dbms_xmldom.makeNode(doc);
    dbms_xmldom.setversion(doc, '1.0');
    dbms_xmldom.setCharset(doc, 'UTF8');
    elem := dbms_xmldom.createElement(doc, 'PartnerInfo');
    dbms_xmldom.setAttribute(elem,'xmlns','EMP');
    cur_node := dbms_xmldom.appendChild(node, dbms_xmldom.makeNode(elem));
    mode_elmn := dbms_xmldom.createElement(doc, 'EMPLOYEE');
    mode_node := dbms_xmldom.appendChild(cur_node,dbms_xmldom.makeNode(mode_elmn));
    BEGIN
    SELECT value(e) INTO l_xmltype
    FROM TABLE(XMLSequence(Cursor(SELECT * FROM EMP1 where EMPNO=7501))) e;
    child_document := DBMS_XMLDOM.newDOMDocument(l_xmltype);
    root_node_data1 := dbms_xmldom.importNode(doc,dbms_xmldom.makeNode(dbms_xmldom.getDocumentElement(child_document)),TRUE);
    root_node_data1 := DBMS_XMLDOM.appendChild(root_node_data, root_node_data1);
    EXCEPTION
    WHEN OTHERS THEN
    Dbms_Output.Put_Line('Error in SELECT stmt(UC_PARTNER_MS):::'||'error::'||SQLERRM);
    END;
    dbms_lob.createtemporary(v_doc, true);
    dbms_xmldom.writeToClob(doc,v_doc,'UTF8');
    v_EMP:= v_doc;
    dbms_xmldom.writeToFile(DOC,v_output_filename,'UTF8');
    dbms_xmldom.freeDocument(doc);
    --Dbms_Output.Put_Line('THE OUTPUT IS::'||V_EMP);
    EXCEPTION
    WHEN OTHERS THEN
    Dbms_Output.Put_Line('Error in SELECT stmt(UC_PARTNER_MS):::'||'error::'||SQLERRM);
    END;
    The xml file is 'EMP_XML_FILE.xml'
    <empno>U++kYmcVuGchxbh+++++++++++++++1+</empno>
    <empname>J</empname>
    suppose the empno 7501 is not available in our emp table,
    i got error
    ORA-03113: end-of-file on communication channel
    how to handle xmldom with no data values.
    by
    siva

    hi,
    please give the solution
    by
    siva

  • Error when using DBMS_XMLDOM package

    Hello,
    I have created a set of triggers that use the DBMS_XMLDOM packages. These triggers were created on a Win 2k install of 9.2.0.2.1. A brand new user was created and a specific set of permissions granted. The permissions were:
    GRANT CONNECT, RESOURCE, AQ_ADMINISTRATOR_ROLE, AQ_USER_ROLE
    GRANT EXECUTE ON DBMS_AQADM
    GRANT EXECUTE ON DBMS_AQ
    grant execute on dbms_aqin
    execute dbms_java.grant_permission('<USER>', 'java.net.SocketPermission', 'localhost:1024-', 'accept, listen, resolve');
    execute dbms_java.grant_permission( '<USER>', 'SYS:java.lang.RuntimePermission', ' getClassLoader', '' )
    execute dbms_java.grant_permission( '<USER>', 'SYS:java.lang.RuntimePermission' , 'setContextClassLoader', '' )
    I then went to install these triggers on our application database server. This is a Solaris installation that started out as 9.2.0.1.0 and was then upgraded to 9.2.0.2.0. I created the user and granted the exact same permissions on this database. However, everytime I attempt to execute the triggers, or anything else that uses DBMS_XMLDOM packages, I get the following error:
    doc dbms_xmldom.DOMDocument;
    ERROR at line 3:
    ORA-06550: line 3, column 11:
    PLS-00201: identifier 'DBMS_XMLDOM.DOMDOCUMENT' must be declared
    I did not create the application database instance on the Solaris machine, but from what I've talked with the DBA, it was created as a general database, which is how I created my test databases. I also verified that the users in both databases have Execute on SYS.XMLDOM granted.
    Any ideas on why I might be getting this error?
    Thanks,
    Andrew

    When I try the describe, it says object not found. If I go into OEM, I don't see that package either. Again, I didn't create that database, but I thought the XML DB stuff was installed by default with the database. Is there a way to add that package after the database is created?
    Thanks,
    Andrew

  • Error when generating XML

    Hi, I am trying to generate an XML file using the code below and receive the following error;
    failed ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00231: invalid character 60 ('<') found in a Name or Nmtoken
    Error at line 47102066
    The code inside the procedure is:
    xml_result xmltype;
    doc        dbms_xmldom.DOMDocument;
    ctx DBMS_XMLGEN.ctxHandle;
    vv_exit_code varchar2(5);
    vv_ctx_open varchar2(1) := 'N';
      BEGIN
    vv_exit_code := 'XML1';
      ctx := dbms_xmlgen.newcontext(p_sql);
      vv_ctx_open := 'Y';
    DBMS_OUTPUT.put_line(vv_exit_code);
    vv_exit_code := 'XML2';
      DBMS_XMLGEN.SETCONVERTSPECIALCHARS (ctx,TRUE);
    DBMS_OUTPUT.put_line(vv_exit_code);
      vv_exit_code := 'XML3';
    xml_result := dbms_xmlgen.getXMLType(ctx);
    DBMS_OUTPUT.put_line(vv_exit_code);
    IF xml_result is not null THEN
         vv_exit_code := 'XML4';
         doc := dbms_xmldom.newDOMDocument(xml_result);
    DBMS_OUTPUT.put_line(vv_exit_code);
         vv_exit_code := 'XML5';
         dbms_xmldom.writeToFile(doc,p_dir||'/'||p_fileName, 'ISO-8859-1');
    DBMS_OUTPUT.put_line(vv_exit_code);
         vv_exit_code := 'XML6';
         dbms_xmldom.freeDocument(doc);
         p_xml_created := 'TRUE';
    DBMS_OUTPUT.put_line(vv_exit_code);
    ELSE
        p_xml_created := 'FALSE';
    END IF;
    DBMS_XMLGEN.CLOSECONTEXT (ctx);
    vv_ctx_open := 'N';
    EXCEPTION
         WHEN out_of_process_memory THEN
        IF vv_ctx_open = 'Y' THEN
            DBMS_XMLGEN.CLOSECONTEXT (ctx);
        END IF;
        gv_err_msg := substr(sqlerrm,1,2000);
        DBMS_OUTPUT.put_line(gv_process_name||' failed '||gv_err_msg);
        RAISE_APPLICATION_ERROR(-20906,gv_process_name||' failed'||gv_err_msg);
          dbms_output.put_line('XML_EXPORT failed (out_of_process_memory exception) executing '||p_sql);
          raise_application_error(-20906,'XML_EXPORT (out_of_process_memory exception) failed executing '||p_sql);
        WHEN OTHERS THEN
        IF vv_ctx_open = 'Y' THEN
            DBMS_XMLGEN.CLOSECONTEXT (ctx);
        END IF;
        if xml_result is NULL then
              gv_err_msg := substr(sqlerrm,1,2000);
        DBMS_OUTPUT.put_line(gv_process_name||' failed '||gv_err_msg);
        RAISE_APPLICATION_ERROR(-20906,gv_process_name||' failed'||gv_err_msg);
              dbms_output.put_line('XML_EXPORT failed (xml results are NULL) executing '||p_sql);
              raise_application_error(-20906,'XML_EXPORT (xml results are NULL) failed executing '||p_sql);
        else
        gv_err_msg := substr(sqlerrm,1,2000);
        DBMS_OUTPUT.put_line(gv_process_name||' failed '||gv_err_msg);
          dbms_output.put_line('XML_EXPORT failed (others exception) executing '||p_sql);
          DBMS_OUTPUT.put_line('Export Directory is: '||p_dir||'/'||p_fileName);
          raise_application_error(-20906,'XML_EXPORT (others exception) failed executing '||p_sql);
    end if;
    I have run the p_sql separately and have no issue. The p_sql is select * from <viewname> where date_id > '20100901' and date_id < '20100930'; (For security reasons I am choosing to leave off specific table/view/column names). I have run this procedure with other date ranges and it works for all the views we are using. I have examined all freeform data (data entered by the user without restriction) and none has a '>' in it during this time period.

    All the column names are valid XML names as this returned for other date ranges (as stated). The oracle version is 11G. This code is encapsulated in a function with the following signature:
    PROCEDURE sql_to_xml(p_sql IN VARCHAR2, p_fileName IN VARCHAR2, p_dir IN VARCHAR2, p_xml_created OUT VARCHAR2)
    To test, I have been calling the package with the sql as I indicated originally, a filename, the unix directory to write to, and a global out variable. Again, as I originally stated, this has been run successfully for other date ranges for the same table, but only fails in a specific range.
    As for the issue with the line number it isn't a copy paste error at all. My total code for this package has 84 lines (including comments etc) (i removed function signature when quoting the code above). The line error message confused me as well, which was part of what I hoped someone else who had done XML exporting would know of. My assumption was that the line number was the line of the XML file, not the code. However because it fails it won't create the XML server onto the directory so I cannot view it and see easily where it breaks.
    You are correct that line 52 makes 54 and 55 useless. I think that was a relic of a previous version and I forgot to remove 52. I did so and will see if the below error is raised.
    I forgot to state that the DBMS_OUTPUT does show XML3 indicating that either XML_RESULT is null or that it breaks at line 19 (because DBMS_OUTPUT never prints XML4). Because you caught the issue with line 52-55, that may be why the null error never was being raised. I am rerunning to verify that xml_result is not null (ie: the null exception raised from the if on line 49 does not trigger).

  • Xmldom.writeToClob error. [URGENT]

    Any idea why I get the following error when I call:
    xmldom.writeToClob(root, xml_out);
    ORA-20000: An internal error has occurred: CLOB to write to can not be null ORA-06512: at "XML.XMLDOM", line 37 ORA-06512: at "XML.XMLDOM", line 358 ORA-06512: at line 131
    'xml_out' is initialised with null, but 'root' have some nodes and elements, but no text nodes. I do not get this error if I use
    xmldom.writeToBuffer(root, v_xml);
    Thanks
    null

    Thx for your response
    the program looks like this:
    I executed it from a Form;
    PROCEDURE PRUEBA IS
    xml clob;
    vxml varchar2(100);
    len integer := 1;
    pos integer := 1;
    f utl_file.file_type;
    doc xmldom.DOMDocument;
    ppal_node xmldom.DOMNode;
    main_node xmldom.DOMNode;
    root_node xmldom.DOMNode;
    user_node xmldom.DOMNode;
    tercer_node xmldom.DOMNode;
    item_node xmldom.DOMNode;
    ppal_elmt xmldom.DOMElement;
    root_elmt xmldom.DOMElement;
    item_elmt xmldom.DOMElement;
    item_text xmldom.DOMText;
    --Elementos de la cabecera
    header_pi xmldom.DOMProcessingInstruction;
    header_node xmldom.DOMNode;
    CURSOR MODULOS IS
    SELECT T_COAPI AS COAPI,
    T_DNAPI AS DNAPI     
    FROM     T
    WHERE     T_COAPI = 'PES';
    BEGIN
    --Creamos un nuevo DOM document
    doc := xmldom.newDOMDocument();
    ppal_node := xmldom.makeNode(doc);
    FOR Modulo IN Modulos LOOP
    -- El nodo es cada modulo
    root_elmt := xmldom.createElement(doc, 'Modulo');
    root_node := xmldom.appendChild(main_node, xmldom.makeNode(root_elmt));
    --COAPI
    item_elmt := xmldom.createElement(doc, lit_COAPI);
    item_node := xmldom.appendChild(root_node, xmldom.makeNode(item_elmt));
    item_text := xmldom.createTextNode(doc, Modulo.COAPI);
    item_node := xmldom.appendChild(item_node, xmldom.makeNode(item_text));
    --DNAPI
    item_elmt := xmldom.createElement(doc, lit_DNAPI);
    item_node := xmldom.appendChild(root_node, xmldom.makeNode(item_elmt));
    item_text := xmldom.createTextNode(doc, Modulo.DNAPI);
    item_node := xmldom.appendChild(item_node, xmldom.makeNode(item_text));
    END LOOP
    f := utl_file.fopen('TEMP_DIR','PRUEBA.xml','w');
    --Obtenemos la longitud del xml lob
    len := dbms_lob.getlength(xml);
    DBMS_LOB.CreateTemporary(xml,TRUE);
    xmldom.writeToClob(doc,xml); -- HERE I GET THE ERROR
    dbms_xmldom.WriteToFile(f,xml);
    WHILE (pos < len) LOOP
    vxml := dbms_lob.substr(xml,100,pos);
    utl_file.put(f,vxml);
    pos := pos+100;
    END LOOP;
    utl_file.fclose(f);
    END;

  • ERROR WITH XMLDOM.WRITETOCLOB

    Hi,
    I have written the following procedure...............
    procedure Prc_UpdateNodes(clString in out clob, nodename varchar2, nodeValue varchar2) is
         l_doc_node xmldom.DOMNode;
         l_xml_out varchar2(2000);
         begin
                   domDocument      := Fn_GetXmlDocument(clString);
                   nodeList           := xmldom.getElementsByTagName(domDocument, nodename);
                   intNoOfNode      := xmldom.getLength(nodeList);
                   l_doc_node := xmldom.item(nodeList, 0);
                   for loopCount_int in 0.. intNoOfNode - 1 loop
         node := XmlDom.item(nodeList, loopCount_int);
                        valueNode := XmlDom.getFirstChild(node);
                        XmlDom.setNodeValue(valueNode,nodeValue);
                   end loop;
                   XmlDom.writeToClob(domDocument,clString);
    end;
    This below XML Is passed as the first parameter
    The output after this operation for an xml should be..
    <ROWSET>
    <ROW>
    <SITE_NO Key="Yes">1</SITE_NO>
    <PARAMETER_VALUE_NO Key="Yes">0</PARAMETER_VALUE_NO>
    <PARENT_PARAMETER_SPEC_NO>0</PARENT_PARAMETER_SPEC_NO>
    <PARAMETER_SPEC_NO>1</PARAMETER_SPEC_NO>
    <REF_TABLE_KEY_NO>0</REF_TABLE_KEY_NO>
    <REF_TABLE_KEY_TYPE>S</REF_TABLE_KEY_TYPE>
    <SEQ_NO>1</SEQ_NO>
    <SUB_SEQN_NO>0</SUB_SEQN_NO>
    <DATA_TYPE_NO>1</DATA_TYPE_NO>
    <INTEGER_VALUE>0</INTEGER_VALUE>
    <STRING_VALUE>00039</STRING_VALUE>
    <NUMERIC_VALUE>0</NUMERIC_VALUE>
    <DATE_VALUE>01/01/1600</DATE_VALUE>
    <CREATED_ON>0</CREATED_ON>
    <MODIFIED_ON>0</MODIFIED_ON></ROW>
    <ROW>
    <SITE_NO Key="Yes">1</SITE_NO>
    <PARAMETER_VALUE_NO Key="Yes">0</PARAMETER_VALUE_NO>
    <PARENT_PARAMETER_SPEC_NO>0</PARENT_PARAMETER_SPEC_NO>
    <PARAMETER_SPEC_NO>2</PARAMETER_SPEC_NO>
    <REF_TABLE_KEY_NO>0</REF_TABLE_KEY_NO>
    <REF_TABLE_KEY_TYPE>S</REF_TABLE_KEY_TYPE>
    <SEQ_NO>2</SEQ_NO><SUB_SEQN_NO>0</SUB_SEQN_NO>
    <DATA_TYPE_NO>2</DATA_TYPE_NO>
    <INTEGER_VALUE>0</INTEGER_VALUE>
    <STRING_VALUE/>
    <NUMERIC_VALUE>0</NUMERIC_VALUE>
    <DATE_VALUE/>
    <CREATED_ON>0</CREATED_ON>
    <MODIFIED_ON>0</MODIFIED_ON>
    </ROW>
    </ROWSET>
    But the output I get is ……….
    <ROWSET>
    <ROW>
    <SITE_NO Key="Yes">1</SITE_NO>
    <PARAMETER_VALUE_NO Key="Yes">0</PARAMETER_VALUE_NO>
    <PARENT_PARAMETER_SPEC_NO>0</PARENT_PARAMETER_SPEC_NO>
    <PARAMETER_SPEC_NO>1</PARAMETER_SPEC_NO>
    <REF_TABLE_KEY_NO>0</REF_TABLE_KEY_NO>
    <REF_TABLE_KEY_TYPE>S</REF_TABLE_KEY_TYPE>
    <SEQ_NO>1</SEQ_NO>
    <SUB_SEQN_NO>0</SUB_SEQN_NO>
    <DATA_TYPE_NO>1</DATA_TYPE_NO>
    <INTEGER_VALUE>0</INTEGER_VALUE>
    <STRING_VALUE>00039</STRING_VALUE>
    <NUMERIC_VALUE>0</NUMERIC_VALUE>
    <DATE_VALUE>01/01/1600</DATE_VALUE>
    <CREATED_ON>0</CREATED_ON>
    <MODIFIED_ON>0</MODIFIED_ON></ROW>
    <ROW>
    <SITE_NO Key="Yes">1</SITE_NO>
    <PARAMETER_VALUE_NO Key="Yes">0</PARAMETER_VALUE_NO>
    <PARENT_PARAMETER_SPEC_NO>0</PARENT_PARAMETER_SPEC_NO>
    <PARAMETER_SPEC_NO>2</PARAMETER_SPEC_NO>
    <REF_TABLE_KEY_NO>0</REF_TABLE_KEY_NO>
    <REF_TABLE_KEY_TYPE>S</REF_TABLE_KEY_TYPE>
    <SEQ_NO>2</SEQ_NO><SUB_SEQN_NO>0</SUB_SEQN_NO>
    <DATA_TYPE_NO>2</DATA_TYPE_NO>
    <INTEGER_VALUE>0</INTEGER_VALUE>
    <STRING_VALUE/>
    <NUMERIC_VALUE>0</NUMERIC_VALUE>
    <DATE_VALUE/>
    <CREATED_ON>0</CREATED_ON>
    <MODIFIED_ON>0</MODIFIED_ON>
    </ROW>
    </ROWSET>
    0</MODIFIED_ON>
    </ROW>
    </ROWSET>
    The letter in bold above are the newly introduced junk letters
    I think this problem is due to the buffer isssues………….
    Do we have any solution for clearing the buffer….
    Also this error doesnt occur all the time.........
    Sometimes it comes, Sometimes it works fine
    The error is introduced during execution of the statement
    XmlDom.writeToClob(domDocument,clString);
    Can anyone help me on this front?????
    Thanks
    Message was edited by:
    user609257

    Thx for your response
    the program looks like this:
    I executed it from a Form;
    PROCEDURE PRUEBA IS
    xml clob;
    vxml varchar2(100);
    len integer := 1;
    pos integer := 1;
    f utl_file.file_type;
    doc xmldom.DOMDocument;
    ppal_node xmldom.DOMNode;
    main_node xmldom.DOMNode;
    root_node xmldom.DOMNode;
    user_node xmldom.DOMNode;
    tercer_node xmldom.DOMNode;
    item_node xmldom.DOMNode;
    ppal_elmt xmldom.DOMElement;
    root_elmt xmldom.DOMElement;
    item_elmt xmldom.DOMElement;
    item_text xmldom.DOMText;
    --Elementos de la cabecera
    header_pi xmldom.DOMProcessingInstruction;
    header_node xmldom.DOMNode;
    CURSOR MODULOS IS
    SELECT T_COAPI AS COAPI,
    T_DNAPI AS DNAPI     
    FROM     T
    WHERE     T_COAPI = 'PES';
    BEGIN
    --Creamos un nuevo DOM document
    doc := xmldom.newDOMDocument();
    ppal_node := xmldom.makeNode(doc);
    FOR Modulo IN Modulos LOOP
    -- El nodo es cada modulo
    root_elmt := xmldom.createElement(doc, 'Modulo');
    root_node := xmldom.appendChild(main_node, xmldom.makeNode(root_elmt));
    --COAPI
    item_elmt := xmldom.createElement(doc, lit_COAPI);
    item_node := xmldom.appendChild(root_node, xmldom.makeNode(item_elmt));
    item_text := xmldom.createTextNode(doc, Modulo.COAPI);
    item_node := xmldom.appendChild(item_node, xmldom.makeNode(item_text));
    --DNAPI
    item_elmt := xmldom.createElement(doc, lit_DNAPI);
    item_node := xmldom.appendChild(root_node, xmldom.makeNode(item_elmt));
    item_text := xmldom.createTextNode(doc, Modulo.DNAPI);
    item_node := xmldom.appendChild(item_node, xmldom.makeNode(item_text));
    END LOOP
    f := utl_file.fopen('TEMP_DIR','PRUEBA.xml','w');
    --Obtenemos la longitud del xml lob
    len := dbms_lob.getlength(xml);
    DBMS_LOB.CreateTemporary(xml,TRUE);
    xmldom.writeToClob(doc,xml); -- HERE I GET THE ERROR
    dbms_xmldom.WriteToFile(f,xml);
    WHILE (pos < len) LOOP
    vxml := dbms_lob.substr(xml,100,pos);
    utl_file.put(f,vxml);
    pos := pos+100;
    END LOOP;
    utl_file.fclose(f);
    END;

  • Utl_file can't read from my directory

    hello
    I am trying to load XML data from an xml file into a CLOB object and i am getting an error in the unlikely segment of the code. The following code can't read from the directory specified by the utl_file_dir parameter.
    I am setting the "utl_file_dir" parameter at the sys level and dont have it in the SPFILE (initialization) file.
    sys@LOCAL> ALTER SYSTEM SET UTL_FILE_DIR='C:\XMLBOOK\Examples\Chapter25\src\xml' SCOPE=SPFILE;
    System altered.
    sys@LOCAL> shutdown
    sys@LOCAL> startup
    sys@LOCAL> select name,value from v$parameter where name like '%utl_file_dir%';
    NAME VALUE
    utl_file_dir C:\XMLBOOK\Examples\Chapter25\src\xml
    sys@LOCAL> DECLARE
    2 v_xmldoc DBMS_XMLDOM.DOMDocument;
    3 v_parser DBMS_XMLPARSER.parser;
    4 v_out CLOB;
    5 v_dir VARCHAR2(200) :=
    6 'C:\XMLBOOK\Examples\Chapter25\src\xml';
    7 BEGIN
    8 -- New parser
    9 v_parser := DBMS_XMLPARSER.newParser;
    10 -- Setting up the parsing parameters
    11 DBMS_XMLPARSER.setValidationMode(v_parser, FALSE);
    12 DBMS_XMLPARSER.setPreserveWhiteSpace(v_parser, TRUE);
    13 -- The v_dir has to be a valid directory in the UTL_FILE_DIR
    14 DBMS_XMLPARSER.setBaseDir(v_parser, v_dir);
    15 -- Parsing the XML file
    16 DBMS_XMLPARSER.parse(v_parser, 'contact.xml');
    17 -- Getting the XML DOMDocument
    18 v_xmldoc := DBMS_XMLPARSER.getDocument(v_parser);
    19 -- Print out the result
    20 DBMS_LOB.createtemporary(v_out,FALSE,DBMS_LOB.SESSION);
    21 DBMS_XMLDOM.writetoClob(v_xmldoc, v_out);
    22 DBMS_XMLDOM.writetoFile(v_xmldoc,v_dir||'/out.xml');
    23 :out := v_out;
    24 DBMS_LOB.freetemporary(v_out);
    25 END;
    26 /
    DECLARE
    ERROR at line 1:
    ORA-29280: invalid directory path
    ORA-06512: at "SYS.UTL_FILE", line 18
    ORA-06512: at "SYS.UTL_FILE", line 424
    ORA-06512: at "XDB.DBMS_XSLPROCESSOR", line 15
    ORA-06512: at "XDB.DBMS_XMLPARSER", line 90
    ORA-06512: at line 16
    sys@LOCAL>
    It would be great if i get some help here.
    Thanks.

    try this:
    create directory test_d as 'F:\OracleXML';
    DECLARE
    v_xmldoc DBMS_XMLDOM.DOMDocument;
    v_parser DBMS_XMLPARSER.parser;
    v_out CLOB;
    -- v_dir VARCHAR2(200) := 'F:\ORACLEXML'; don use this
    BEGIN
    v_parser := DBMS_XMLPARSER.newParser;
    DBMS_XMLPARSER.setValidationMode(v_parser, FALSE);
    DBMS_XMLPARSER.setPreserveWhiteSpace(v_parser, TRUE);
    DBMS_XMLPARSER.setBaseDir(v_parser, 'TEST_D');
    DBMS_XMLPARSER.parse(v_parser, 'newtab.xml');
    v_xmldoc := DBMS_XMLPARSER.getDocument(v_parser);
    DBMS_LOB.createtemporary(v_out,FALSE,DBMS_LOB.SESSION);
    DBMS_XMLDOM.writetoClob(v_xmldoc, v_out);
    DBMS_XMLDOM.writetoFile(v_xmldoc,'TEST_D'||'/out.xml');
    -- :out := v_out;
    DBMS_LOB.freetemporary(v_out);
    END;

  • How to solve this &(amberstand of lessthanand &(amberstand of greaterthan

    hi,
    i have below block,
    DECLARE
    doc dbms_xmldom.DOMDocument;
    node dbms_xmldom.DOMNode;
    elem dbms_xmldom.DOMElement;
    cur_node dbms_xmldom.DOMNode;
    root_elem_data dbms_xmldom.DOMElement;
    root_elem_tab dbms_xmldom.DOMElement;
    root_node_data dbms_xmldom.DOMNode;
    mode_elmn dbms_xmldom.DOMElement;
    mode_node dbms_xmldom.DOMNode;
    mode_text dbms_xmldom.DOMText;
    V_CLOB CLOB;
    v_doc CLOB;
    v_EMP CLOB;
    v_output_filename VARCHAR2(300) := 'SPOOL_DIR/'||'EMP_XML_FILE.xml';
    BEGIN
    doc := dbms_xmldom.newDOMDocument;
    node := dbms_xmldom.makeNode(doc);
    dbms_xmldom.setversion(doc, '1.0');
    dbms_xmldom.setCharset(doc, 'UTF8');
    elem := dbms_xmldom.createElement(doc, 'PartnerInfo');
    dbms_xmldom.setAttribute(elem,'xmlns','EMP');
    cur_node := dbms_xmldom.appendChild(node, dbms_xmldom.makeNode(elem));
    mode_elmn := dbms_xmldom.createElement(doc, 'EMPLOYEE');
    mode_node := dbms_xmldom.appendChild(cur_node,dbms_xmldom.makeNode(mode_elmn));
    BEGIN
    SELECT value(e).getClobVal() INTO V_CLOB
    FROM TABLE(XMLSequence(Cursor(SELECT * FROM EMP1 where EMPNO=7501))) e;
    Dbms_Output.Put_Line('THE OUTPUT IS::'||V_CLOB);
    mode_text := dbms_xmldom.createTextNode(doc,V_CLOB);
    mode_node := dbms_xmldom.appendChild(mode_node,dbms_xmldom.makeNode(mode_text));
    EXCEPTION
    WHEN OTHERS THEN
    Dbms_Output.Put_Line('Error in SELECT stmt(UC_PARTNER_MS):::'||'error::'||SQLERRM);
    END;
    dbms_lob.createtemporary(v_doc, true);
    dbms_xmldom.writeToClob(doc,v_doc,'UTF8');
    v_EMP:= v_doc;
    dbms_xmldom.writeToFile(DOC,v_output_filename,'UTF8');
    dbms_xmldom.freeDocument(doc);
    --Dbms_Output.Put_Line('THE OUTPUT IS::'||V_EMP);
    EXCEPTION
    WHEN OTHERS THEN
    Dbms_Output.Put_Line('Error in SELECT stmt(UC_PARTNER_MS):::'||'error::'||SQLERRM);
    END;
    The xml file is 'EMP_XML_FILE.xml'
    &lt;empno&gt;U++kYmcVuGchxbh+++++++++++++++1+&lt;/empno&gt;
    &lt;empname&gt;J&lt;/empname&gt;
    how to solve this <(amberstand of lessthan and >(amberstand of lgreaterthan) instead of > and <
    i am trying to write xml in spoo_dir directory.when i am open in notepad or any other editor its showing amberstand of lt and amberstand of gt instead of > and >.But its open in internet explorer it showing correctly.i don't know whats problem in xml file.i am using below mentioned statement.
    v_emp is clob with out parameter
    dbms_lob.createtemporary(v_doc, true);
    dbms_xmldom.writeToClob(doc,v_doc,'UTF8');
    v_emp:= v_doc;
    query using
    SELECT value(e).getClobVal() INTO V_CLOB
    FROM TABLE(XMLSequence(Cursor(SELECT * FROM EMP1 where EMPNO=7501))) e;
    can u please give solution for this problem.its urgent please.
    by
    siva

    Continued discussion previously started at {message:id=3961457}

  • Queries on CLOB

    Hi all,
    1. What is the maximum character bytes a CLOB object can hold ? Is it 4GB-1?
    2. I have read some where that, writeclob() gives the erroneous results and is fixed in Oracle 9i, Release 9.2.0.4.0. Please confirm??
    3. What are the implications of using CLOB in the procedure? What are the things need to be considered while using a CLOB and writeClob() ?
    4. I am writing DBMS_XMLDOM.DOMDocument object to a CLOB and iterating through the CLOB to print the contents of the CLOB into XML file and getting erroneous results! Any suggestions would be of great help?
    Thanks in advance.
    Vikram

    Here are the details:
    Which db release are you working with ?
    Oracle 9i, Release 9.2.0.6.0
    What errors are you ecountering (exact error message, symptoms (erroneous results is not very descriptive)) ?. Can you post sample code.
    When I am trying to write the data from CLOB to XML, the data that is getting printed is incomplete. It is truncating few KB's of data. But not throwing any errors. Here is the code:
    DECLARE
    v_output utl_file.file_type;
    i_clob clob;
    v_amt NUMBER DEFAULT 8000;
    v_offset NUMBER DEFAULT 1;
    v_length NUMBER; --DEFAULT nvl(dbms_lob.getlength(i_clob),0);
    v_lenght_c NUMBER;
    v_buffer NVARCHAR2(32000);
    v_buffer2 NVARCHAR2(32000);
    v_DOMDoc DBMS_XMLDOM.DOMDocument;
    v_MainNode DBMS_XMLDOM.DOMNode;
    v_RootElem DBMS_XMLDOM.DOMElement;
    v_RootNode DBMS_XMLDOM.DOMNode;
    counter INTEGER;
    total_size INTEGER;
    v_id table.ID%TYPE;
    v_temp_id table.TEMP_ID%TYPE;
    v_created_by table.CREATED_BY%TYPE;
    CURSOR class_cur IS
    SELECT ID,TEMP_ID,CREATED_BY
    FROM table WHERE column like 'Post%';
    BEGIN
    counter := 0;
    SELECT COUNT(1) INTO total_size FROM table WHERE custom2 like 'Post%';
    v_DOMDoc := DBMS_XMLDOM.newDOMDocument();
    v_MainNode := DBMS_XMLDOM.makeNode(v_DOMDoc);
    v_RootElem := DBMS_XMLDOM.createElement(v_DOMDoc, 'classes');
    v_RootNode := DBMS_XMLDOM.appendChild(v_MainNode, DBMS_XMLDOM.makeNode(v_RootElem) );
    OPEN class_cur;
    LOOP
    FETCH class_cur INTO v_id, v_offerng_temp_id, v_created_by;
    counter := counter + 1;
    v_CustElem := DBMS_XMLDOM.createElement(v_DOMDoc, 'class');
    v_CustNode := DBMS_XMLDOM.appendChild(v_RootNode, DBMS_XMLDOM.makeNode(v_CustElem));
    DBMS_XMLDOM.setAttribute(v_CustElem, 'xid', v_id);
    DBMS_XMLDOM.setAttribute(v_CustElem, 'sd', v_temp_id);
    DBMS_XMLDOM.setAttribute(v_CustElem, 'xloc', v_created_by);
    IF counter = total_size THEN
    EXIT;
    END IF;
    END LOOP;
    CLOSE C1;
    --DBMS_XMLDOM.writeToFile(v_DOMDoc, '/xxx/yyy/zzz/test.xml');
    dbms_xmldom.writeToClob(v_DOMDoc, i_clob);
    v_length:= nvl(dbms_lob.getlength(i_clob),0);
    v_lenght_c := v_length;
    v_output := utl_file.fopen_nchar('/xxx/yyy/zzz', 'test_extract.xml', 'w',32767);
    WHILE(v_offset < v_length)
    LOOP
    dbms_lob.read(i_clob, v_amt, v_offset, v_buffer);
    utl_file.put_nchar(v_output, v_buffer);
    utl_file.fflush(v_output);
    v_offset := v_offset + v_amt;
    END LOOP;
    utl_file.fclose(v_output);
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE(Substr(SQLERRM,1,255));
    utl_file.fclose(v_output);
    END;
    What size document are you trying to work with / generate ?.
    I want to generate a file of size <=4GB-1. But the script posted above wokrs fine when the size is 65 KB. But when the file size is >114KB , it is truncating the data.
    The size of the CLOB in bytes in 4Gb-1, however you need to remember that is the NLS_CHARACTERSET is AL32UTF8 then the contents of the CLOB will be UCS-2, so each characeter will take up 2 bytes.
    NLS_CHARACTERSET is AL32UTF8 in the DB I am using. Please let me know your thoughts on this.
    Thanks,
    Vikram

  • Another nested xmlagg

    Hi folks,
    I have the following query:
    select xmlroot(
         xmlelement
              EMSData,
    XMLForest(
    v_DailyStartDate as "DailyStartDate",
    v_WeeklyStartDate as "WeeklyStartDate",
    v_MonthlyStartDate as "MonthlyStartDate"
              XMLAGG
                   XMLELEMENT
                        year,
                        xmlattributes(calyear),
                        xmlagg
                             xmlelement
                                  interval,
                                  xmlattributes(intervalType as "Type",intervalValue as "Value"),
                                  xmlelement
                                       data,
                                       xmlattributes(provider),
                                       xmlforest
                                            bytes,
                                            files
                             order by orderBy,intervalvalue desc
                   order by calyear desc
         ), version '1.0').getClobVal() into l_xml
    from myTable
    group by calyear;
    Which produces the following XML:
    <?xml version="1.0"?>
    <EMSDATA>
    <DailyStartDate>30-SEP-11</DailyStartDate>
    <WeeklyStartDate>01-OCT-08</WeeklyStartDate>
    <MonthlyStartDate>01-JAN-02</MonthlyStartDate>
    <YEAR CALYEAR="2011">
    <INTERVAL Type="DAY" Value="333">
    <DATA PROVIDER="ALPHA">
    <BYTES>16734642488</BYTES>
    <FILES>2333</FILES>
    </DATA>
    </INTERVAL>
    <INTERVAL Type="DAY" Value="333">
    <DATA PROVIDER="BETA">
    <BYTES>2580914653</BYTES>
    <FILES>8148</FILES>
    </DATA>
    </INTERVAL>
    <INTERVAL Type="DAY" Value="332">
    <DATA PROVIDER="ALPHA">
    <BYTES>24516086977</BYTES>
    <FILES>2315</FILES>
    </DATA>
    </INTERVAL>
    <INTERVAL Type="DAY" Value="332">
    <DATA PROVIDER="BETA">
    <BYTES>1090547502078</BYTES>
    <FILES>16548</FILES>
    </DATA>
    </INTERVAL>
    </YEAR>
    </EMSDATA>
    What I really want the XML to look like is:
    <?xml version="1.0"?>
    <EMSDATA>
    <DailyStartDate>30-SEP-11</DailyStartDate>
    <WeeklyStartDate>01-OCT-08</WeeklyStartDate>
    <MonthlyStartDate>01-JAN-02</MonthlyStartDate>
    <YEAR CALYEAR="2011">
    <INTERVAL Type="DAY" Value="333">
    <DATA PROVIDER="ALPHA">
    <BYTES>16734642488</BYTES>
    <FILES>2333</FILES>
    </DATA>
    <DATA PROVIDER="BETA">
    <BYTES>2580914653</BYTES>
    <FILES>8148</FILES>
    </DATA>
    </INTERVAL>
    <INTERVAL Type="DAY" Value="332">
    <DATA PROVIDER="ALPHA">
    <BYTES>24516086977</BYTES>
    <FILES>2315</FILES>
    </DATA>
    <DATA PROVIDER="BETA">
    <BYTES>1090547502078</BYTES>
    <FILES>16548</FILES>
    </DATA>
    </INTERVAL>
    </YEAR>
    </EMSDATA>
    I know it is something simple but I'm brain fried.
    Please advise.
    Best,
    Nat

    I'm thinking I need a nested select statement such as:
    select xmlroot
         xmlelement
              EMSData,
              XMLForest
                   v_DailyStartDate as "DailyStartDate",
                   v_WeeklyStartDate as "WeeklyStartDate",
                   v_MonthlyStartDate as "MonthlyStartDate"
              XMLAGG
                   XMLELEMENT
                        year,
                        xmlattributes(calyear),
                             select
                             xmlagg
                                  xmlelement
                                       interval,
                                       xmlattributes(intervalType as "Type",intervalValue as "Value"),
                                       xmlelement
                                            data,xmlattributes(provider),
                                            xmlelement
                                                 "BYTES", bytes
                                            xmlelement
                                                 "FILES",files
                             ) from mytable
                   order by calyear desc
         version '1.0'
    ).getClobVal() into l_xml
    from mytable
    group by calyear;
    However, when I try this Oracle just sits there. So, I decided to just try the nested sql itself to see the results. I ran the following:
    declare
    l_xml clob;
    myFilename varchar2(50) := 'myTestXML';
    v_ctx DBMS_XMLGen.ctxHandle;
    xmldoc dbms_xmldom.DOMDocument;
    begin
    select
    xmlroot(
                             xmlagg
                                  xmlelement
                                       interval,
                                       xmlattributes(intervalType as "Type",intervalValue as "Value"),
                                       xmlelement
                                            data,xmlattributes(provider),
                                            xmlforest
                                                 bytes,
                                                 files
         version '1.0'
    ).getClobVal() into l_xml
    from mytable;
    xmldoc := dbms_xmldom.newDOMDocument(l_xml);
    dbms_xmldom.writeToFile(xmldoc, 'ERR_DIR'||'/'||myFilename||'.xml');
    dbms_xmldom.freeDocument(xmldoc);
    end;
    I get this error:
    ERROR at line 1:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00245: extra data after end of document
    Error at line 8
    ORA-06512: at "XDB.DBMS_XMLDOM", line 5345
    ORA-06512: at "XDB.DBMS_XMLDOM", line 5370
    ORA-06512: at "XDB.DBMS_XMLDOM", line 5290
    ORA-06512: at line 42
    Can anyone offer insight as to what I'm doing wrong.
    Best,
    Nat
    Edited by: 899806 on Dec 1, 2011 9:15 AM
    Edited by: 899806 on Dec 1, 2011 1:45 PM

  • How to export a data as an XML file from oracle data base?

    could u pls tell me the step by step procedure for following questions...? how to export a data as an XML file from oracle data base? is it possible? plz tell me itz urgent requirement...
    Thankz in advance
    Bala

    SQL> SELECT * FROM v$version;
    BANNER
    Oracle DATABASE 11g Enterprise Edition Release 11.1.0.6.0 - Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE    11.1.0.6.0      Production
    TNS FOR 32-bit Windows: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    5 rows selected.
    SQL> CREATE OR REPLACE directory utldata AS 'C:\temp';
    Directory created.
    SQL> declare                                                                                                               
      2    doc  DBMS_XMLDOM.DOMDocument;                                                                                       
      3    xdata  XMLTYPE;                                                                                                     
      4                                                                                                                        
      5    CURSOR xmlcur IS                                                                                                    
      6    SELECT xmlelement("Employee",XMLAttributes('http://www.w3.org/2001/XMLSchema' AS "xmlns:xsi",                       
      7                                  'http://www.oracle.com/Employee.xsd' AS "xsi:nonamespaceSchemaLocation")              
      8                              ,xmlelement("EmployeeNumber",e.empno)                                                     
      9                              ,xmlelement("EmployeeName",e.ename)                                                       
    10                              ,xmlelement("Department",xmlelement("DepartmentName",d.dname)                             
    11                                                      ,xmlelement("Location",d.loc)                                     
    12                                         )                                                                              
    13                   )                                                                                                    
    14     FROM   emp e                                                                                                       
    15     ,      dept d                                                                                                      
    16     WHERE  e.DEPTNO=d.DEPTNO;                                                                                          
    17                                                                                                                        
    18  begin                                                                                                                 
    19    OPEN xmlcur;                                                                                                        
    20    FETCH xmlcur INTO xdata;                                                                                            
    21    CLOSE xmlcur;                                                                                                       
    22    doc := DBMS_XMLDOM.NewDOMDocument(xdata);                                                                           
    23    DBMS_XMLDOM.WRITETOFILE(doc, 'UTLDATA/marco.xml');                                                                  
    24  end;                                                                                                                  
    25  /                                                                                                                      
    PL/SQL procedure successfully completed.
    .

Maybe you are looking for

  • Material Master upload problem (LSMW)

    Hi   I am using Standard Batch input program (RMDATIND)  for MM upload i need to validate the old material number if it is already existed in MARA it should throw an error at the end of the processing saying that "Old material number" already existin

  • Downloading iTunes Without QuickTime

    From the latest update from Apple to iTunes users with Windows XP, there have been many having a problem opening iTunes without receiving an error. The latest resolution posted was to download an older version of QuickTime first, and then download iT

  • Accounts Receivable Reports:Table and field required

    Hi experts, My user requires said reports in the following formats: Posting date Invoice no. Customer  code  Invoice amount  Payment received outstandig amount Now i want to customized this reports.I have got table and fields for "posting date,invoic

  • Alternate Items in a BOM

    I have a BOM for X which can make use of any component A or B or C in its BOM. The component A is always procured from China plant to the plant in India. I have set the usage probability of component A as 100 %. But in my case I would require a situa

  • I'm using CS6 created a new document. trying to use my layers and my work keeps going black. when I

    I'm using Photoshop CS6, created a new document. trying to use my layers and my work keeps going black. when I click on the workspace  i am able to see my work but when I move my mouse any little bit it goes black again.