Oracle data to generate XML file

How can I extract Oracle data to generate XML file using pl/sql?
I am using the following version
Oracle8i Enterprise Edition Release 8.1.5.0.0 - Production
PL/SQL Release 8.1.5.0.0 - Production
CORE Version 8.1.3.0.0 - Production
TNS for Solaris: Version 8.1.5.0.0 - Production
NLSRTL Version 3.4.0.0.0 - Production

I don't know if you already resolved this but here's a sample I got.
-- Akadia Create XML docs
-- (c) Akadia AG 2002
-- Requires Oracle 8i or 9i
-- For larger amounts of nodes use 8.1.7.3 with bug fix 2104071 or 9.2
-- Create XML docs using XMLDOM package.
CONNECT sys/manager@sid
GRANT javauserpriv to scott;
GRANT javasyspriv to scott;
GRANT EXECUTE ON xmldom TO scott;
CREATE SYNONYM scott.xmldom FOR SYS.xmldom;
CONNECT scott/tiger@sid
DECLARE
doc xmldom.DOMDocument;
main_node xmldom.DOMNode;
root_node xmldom.DOMNode;
user_node xmldom.DOMNode;
item_node xmldom.DOMNode;
root_elmt xmldom.DOMElement;
item_elmt xmldom.DOMElement;
item_text xmldom.DOMText;
CURSOR get_users(p_deptno NUMBER) IS
SELECT empno
, ename
, deptno
, rownum
FROM emp
WHERE deptno = p_deptno;
BEGIN
-- get document
doc := xmldom.newDOMDocument;
-- create root element
main_node := xmldom.makeNode(doc);
root_elmt := xmldom.createElement(
doc
, 'EMPSET'
-- xmldom.setAttribute(root_elmt, 'xmlns', 'http://www.akadia.com/xml/soug/xmldom');
-- xmldom.setAttribute(root_elmt, 'xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
-- xmldom.setAttribute(root_elmt, 'xsi:schemaLocation', 'http://www.akadia.com/xml/soug/xmldom/emp.xsd');
root_node := xmldom.appendChild(
main_node
, xmldom.makeNode(root_elmt)
FOR get_users_rec IN get_users(10) LOOP
-- create user element with rownum as attribute
item_elmt := xmldom.createElement(
doc
, 'EMP'
xmldom.setAttribute(
item_elmt
, 'num'
, get_users_rec.rownum
user_node := xmldom.appendChild(
root_node
, xmldom.makeNode(item_elmt)
-- create user element: EMP_NO
item_elmt := xmldom.createElement(
doc
, 'EMP_NO'
item_node := xmldom.appendChild(
user_node
, xmldom.makeNode(item_elmt)
item_text := xmldom.createTextNode(
doc
, get_users_rec.empno
item_node := xmldom.appendChild(
item_node
, xmldom.makeNode(item_text)
-- create user element: NAME
item_elmt := xmldom.createElement(
doc
, 'NAME'
item_node := xmldom.appendChild(
user_node
, xmldom.makeNode(item_elmt)
item_text := xmldom.createTextNode(
doc
, get_users_rec.ename
item_node := xmldom.appendChild(
item_node
, xmldom.makeNode(item_text)
-- create user element: DEPT_NO
item_elmt := xmldom.createElement(
doc
, 'DEPT_NO');
item_node := xmldom.appendChild(
user_node
, xmldom.makeNode(item_elmt)
item_text := xmldom.createTextNode(
doc
, get_users_rec.deptno
item_node := xmldom.appendChild(
item_node
, xmldom.makeNode(item_text)
END LOOP;
-- write document to file using default character set from database
xmldom.writeToFile(
doc
, '/tmp/xml/docSample.xml'
-- free resources
xmldom.freeDocument(doc);
END;
-- deal with exceptions
EXCEPTION
WHEN xmldom.INDEX_SIZE_ERR THEN
raise_application_error(-20120, 'Index Size error');
WHEN xmldom.DOMSTRING_SIZE_ERR THEN
raise_application_error(-20120, 'String Size error');
WHEN xmldom.HIERARCHY_REQUEST_ERR THEN
raise_application_error(-20120, 'Hierarchy request error');
WHEN xmldom.WRONG_DOCUMENT_ERR THEN
raise_application_error(-20120, 'Wrong doc error');
WHEN xmldom.INVALID_CHARACTER_ERR THEN
raise_application_error(-20120, 'Invalid Char error');
WHEN xmldom.NO_DATA_ALLOWED_ERR THEN
raise_application_error(-20120, 'Nod data allowed error');
WHEN xmldom.NO_MODIFICATION_ALLOWED_ERR THEN
raise_application_error(-20120, 'No mod allowed error');
WHEN xmldom.NOT_FOUND_ERR THEN
raise_application_error(-20120, 'Not found error');
WHEN xmldom.NOT_SUPPORTED_ERR THEN
raise_application_error(-20120, 'Not supported error');
WHEN xmldom.INUSE_ATTRIBUTE_ERR THEN
raise_application_error(-20120, 'In use attr error');
END;
/

Similar Messages

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

  • Using a data file in jsp to generate xml file

    hi
    can anybody help me to
    how to use a data file generated in unix in jsp to generate xml file.
    by using beans i am able to generate the xml.
    thanks in advance.

    You haven't provided adequate relevant information. If you need help provide proper relevant details.

  • How to generate xml file from an array of data using jQuery

    Hi All,
    Iam facing the problem with diaplaying array of data into a xml file, Actually iam using SAPUI5 commons table to display the backend data, each row in the table has checkbox. If we select each checkbox, iam getting the particular record and push it into an empty array and then i should show that array of data into xml file.

    OData.request 
    requestUri: url,  
    method: "POST",
    headers: {                    
    "X-Requested-With": "XMLHttpRequest",                  
    "Content-Type": "application/atom+xml",
    "DataServiceVersion": "2.0", 
    "Accept": "application/atom+xml,application/atomsvc+xml,application/xml",  
    "X-CSRF-Token": header_xcsrf_token   
    data: requestTableDATAArray
    // Response after posting and set message
    function (data, response) 
    alert(response.body);//gives xml format

  • How to send the dynamically generated XML file to other site for further processing?

    I have a question regarding exchanging data between two systems
    using XSQL servlet. The situation is descrbed as the follows:
    Assume that we have a simple XSQL page named "emp.xsql"
    <?xml version="1.0"?>
    <?-- XSQL page file "emp.xsql" -->
    <xsql:query xmlns:xsql="urn:oracle-xsql" connection="demo" >
    SELECT * FROM EMP
    </xsql:query>
    and we can access it through the HTTP request likes
    http://web_server_name/xsql/emp.xsql.
    Usually we will the returned dynamic XML file and show it on the
    screen. Now the problem is that we don't want to show the
    generated XML file on the calling screen. Instead, we want to
    send the generated XML file to other website for further
    processing, say, using JSP or ASP likes
    http://other_web_server_name/XMLProcessing.jsp?.....
    How can it be implemented using XSQL servlet?
    Any hint and outline of the solution is appreciated.
    Thanks

    Ike,
    Do you have a sample. I am searched so much in this forum for samples. I looked on SAX Parser. I did not find any samples.
    Please help me.
    Thank you for your posting.
    Padma.

  • Generate XML file for payroll result

    Hi,
    I tried to generate XML file for chinese payroll result by t-code: pu12, but i can not find the interface format for china payroll(here is format for other country vesion like international, france...). How can i generate xml file for chinese payroll result. DO i need to create a format type? Is there any other way? thank you in advance.

    Coming back to my question is it really possible to generate bigger XML on 9i.
    Sure. But not in one go.
    I would use SQL/XML functions instead and paginate the result set so that each CLOB chunk doesn't exceed 4GB (or less). Each chunk could then be appended to a file using UTL_FILE.
    Alternatively, as Oracle 9i supports parallel pipelined functions, you could also imagine doing the job in parallel using automatic data partitioning on an input ref cursor.
    That would require some postprocessing steps to rebuild the entire file from the different chunks though.
    See : Pipelined and Parallel Table Functions

  • How to generate XML file from SQL file !

    I am new to XML publisher. I known one way to generate XML file is register one report file in concurrent manager.
    But I want to generate XML file from sql file.
    Could someone show me how to code in sql file, how to register is in concurrent manager.
    Thanks !

    Hi
    Phew ... not sure we have the space here. So I can point you in the right direction:
    1. XML data generation - there are two packages in the db you can use with a plsql procedure, XMLGEN and SQL XML. You can also use java APIs too. Try checking the db documentation and search for the above methods.
    2. Registering the report - the system administrators guide will provide this info. Hooking the program up with XMLP is covered here - http://www.oracle.com/technology/products/applications/publishing/resource/CM%20Whitepaper5.0.pdf
    Regards, Tim

  • Using servlet to generate XML file

    What I want to do is simple but can't work. Hope you guys can give me a hint.
    I succesfully generate XML file in command line using Oracle XML parser and class generator. Then I was trying to do it using servlet. it compiles fine but generate NullPointer exception at the line:
    Emp e1= new Emp(); //Emp is the root of XML
    I suspect the Emp constructor can't correctly find the globalDTD in its superclass -CGDocument. Please note this only happens in servlet setting, not is command line setting. Any suggestion to get arounf this?
    Another unrelated question is that when I create a XML file using the Oracle XML parser, it seems all the elements a file has to be added once, otherwise the compiler will compalain about the missing element. this will be inconvinient when I constructing a big XML file, which I 'd liek to split into small piece and add them up. Maybe there is a good way but I just don't know it.
    my email: [email protected]

    Hi,
    I'm running into the same problem deploying the classes generated by the class generator. Code works fine from JDeveloper, but had to put my DTD in the directory where my classes are. Deploying the classes with Apache's JServ gives me a NullPointer exception on the first addNode method. I guess it can't find the DTD. I tried to put the DTD in many locations but this didn't fix the problem. Any suggestions?
    Steve,
    Did you fix this problem? Thanx!
    null

  • Error while generating XML file through RDF

    Hi,
    I wanted to generate a Report on some business case. For that I need to generate XML file first.
    For generating XML file
    1. I have built an RDF through Reports builder.
    2. Saved the report to local machine with extension .rdf
    3. Moved it to appltop/app/reports/US directory
    4. Registered tha Report with Executable of type Oracle Reports
    5. Defined Concurrent Program with OUTPUT as XML.
    When I submmitted the program, it was giving an error as follows.
    The XML page cannot be displayed
    Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
    A semi colon character was expected. Error processing resource 'https://oaphrd.humana.com/OA_CGI/FNDWRR.exe?temp_id=2088989...
    +<?xml version="1.0" encoding="&Encoding"?>+
    But, when I tried to sane the report directly to a file (file - > generate file -> XML) the XML was generated successfully.
    How to get rid of this. Some one please help me out.
    Thanks !
    Edited by: Rajasekhar Reddy on May 4, 2012 1:23 AM

    Hi,
    I found the issue and corrected it. :)
    This was happened only because of the Version problem of Report Builder with Oracle Applications.
    Reports Builder 10g is not compatiblie with Oracle Applications 11.5.10.
    Oracle 11.5+ will always expect the RDF from Reports 6i version. Because of this, the endocing was damaged.
    You can observe in the earlier post as encoding="&Endoding". Here +&Encoding should be replaced by some encoding mechanism like "UTF-8".+
    Finally corrected the version and got the Output as expected.
    Thanks !

  • Error while generating XML file from rdf report.

    Hi All,
    we are having a rdf report that displays images retrieved from data base. I need to convert this report to xml report(using rtf template).
    when i tried to run the report after changing the output of the concurrent program to "XML", i am getting the below error.
    REP-1295: Data format of column 'PK1_VALUE' is unsupported.
    REP-0069: Internal error
    REP-57054: In-process job terminated:Terminated with error:
    REP-1295: Data format of column 'PK1_VALUE' is unsupported.
    images are stored in BLOB type columns.
    Can anyone help me on this..
    thanks
    gtungala

    Hi Hussein,
    Thank you for the reply.. i was sure that i will get correct response with in a day..
    you people made this as one of the best technical forums..no doubt in that..
    need some more help from you...!
    The metalink docs say that it is not possible to generate xml file as the image is BLOB.
    Can you please tell me any solution for developing xml template(rtf) which can display images that are stored in data base BLOB columns. Even PL/SQL script will do.. I have tried with changing the BLOB to CLOB in rdf query(by calling a function that converts BLOB to CLOB). it didnt help.
    thanks in advance..
    gtungala

  • Pooling data from an XML file to another XML file using File Adapter

    Hi,
    I am trying to Pool data from an XML file to another XML file using File Adapter. I have added "Target Namespace" in both the XML and XSD.The problem is "At the destination given in the FileAdapter" only a blank XML file is created and it doesnot have any data.
    Kindly suggest me some methods
    Thanks in Advance.

    Ok here is a solution with external tables.
    SQL> CREATE DIRECTORY my_xml_dir AS 'E:\oracle\Log_files\UTL_AKIVATST'
    2 /
    Directory created.
    SQL> DROP TABLE my_xml_et
    2 /
    Table dropped.
    SQL> CREATE TABLE my_xml_et
    2 ( EMPNO NUMBER,
    3 EMPNAME VARCHAR2(10),
    4 JOB VARCHAR2(10),
    5 HIREDATE DATE,
    6 SAL NUMBER
    7 )
    8 ORGANIZATION EXTERNAL
    9 (
    10 TYPE ORACLE_LOADER
    11 DEFAULT DIRECTORY my_xml_dir
    12 ACCESS PARAMETERS
    13 (
    14 records delimited by "</EMP>"
    15 badfile my_xml_dir:'empxt%a_%p.bad'
    16 logfile my_xml_dir:'empxt%a_%p.log'
    17 FIELDS
    18 (
    19 filler char(2000) terminated by "<EMP>",
    20 EMPNO char(2000) enclosed by "<EMPNO>" and "</EMPNO>",
    21 EMPNAME char(2000) enclosed by "<ENAME>" and "</ENAME>",
    22 JOB char(2000) enclosed by "<JOB>" and "</JOB>",
    23 HIREDATE char(2000) enclosed by "<HIREDATE>" and "</HIREDATE>",
    24 SAL char(2000) enclosed by "<SAL>" and "</SAL>"
    25 )
    26 )
    27 LOCATION ('emp.xml')
    28 )
    29 PARALLEL
    30 REJECT LIMIT UNLIMITED
    31 /
    Table created.
    SQL> SELECT * FROM my_xml_et
    2 /
    EMPNO EMPNAME JOB HIREDATE SAL
    7369 SMITH CLERK 17-DEC-80 800
    7499 ALLEN SALESMAN 20-FEB-81 1600
    This is the XML file i used emp.xml
    <EMPLOYEES>
    <EMP>
    <EMPNO>7369</EMPNO>
    <ENAME>SMITH</ENAME>
    <JOB>CLERK</JOB>
    <HIREDATE>17-DEC-80</HIREDATE>
    <SAL>800</SAL>
    </EMP>
    <EMP>
    <EMPNO>7499</EMPNO>
    <ENAME>ALLEN</ENAME>
    <JOB>SALESMAN</JOB>
    <HIREDATE>20-FEB-81</HIREDATE>
    <SAL>1600</SAL>
    <COMM>300</COMM>
    </EMP>
    </EMPLOYEES>
    Use this external table to insert into your table.
    Thanks,
    Karthick.

  • Form2xml generate xml files with "??????????" for non-latin characters

    i used form2xml in oracle 10 g suit to convert forms 5   .fmb to .xml . using the command:
    frmf2xml.bat OVERWRITE=YES myform.fmb
    The forms contains arabic character set, but the xml file is generated with character "????????? "  , and the xml file is unusable
    what can i do to keep arabic characters in the generated  xml files.
    Edit:
    I run form2xml on windows xp SP3 with arabic support (codepage =1256)
    The xml file is generated as UTF-8

    I resolved the problem.
    step1: search in the registry for every NLS_Lang key and modify its value to codepage 1256 using regedit
    step2: in control panel-Region and Language , I  modified language to be Arabic
    Now every thing is good

  • Permission Denied error generating XML file

    We’re using ODI to write out files to a Windows CIFS file system through an agent installed on the ODI Unix server. In order to do this, we had to create the agent using a user ID that had permission to write to the Windows file system. For writing out flat files, this worked great; we have no problems at all.
    However, for writing out XML files to the file system, we’re getting an error that says Permission Denied. We do NOT get the error if we write the XML to a Unix directory, only if we attempt to write it to the CIFS file system. I have two questions:
    1.     Is ODI able to execute against a Windows CIFS file system from UNIX to generate XML files?
    2.     If so, is there a list of permissions required on the fileshare that the ODI needs to generate the XML?
    Below is the exact error we’re getting:
    0 : null : java.sql.SQLException: Could not save the file /mdm_conversion/TST/2.lsm because a class java.io.IOException occurred and said: Permission denied
    Has anyone ever performed something like this or encountered a similar problem?

    Hi,
    I found the issue and corrected it. :)
    This was happened only because of the Version problem of Report Builder with Oracle Applications.
    Reports Builder 10g is not compatiblie with Oracle Applications 11.5.10.
    Oracle 11.5+ will always expect the RDF from Reports 6i version. Because of this, the endocing was damaged.
    You can observe in the earlier post as encoding="&Endoding". Here +&Encoding should be replaced by some encoding mechanism like "UTF-8".+
    Finally corrected the version and got the Output as expected.
    Thanks !

  • Generate XML-Files 4Gigabyte

    Hi,
    I must generate very big XML-Files(Size > 4GB)
    Our datasoure are saved in relational tables.
    From that tables we want to generate xml-Files.
    We used DBMS_LOB but we have problems with clob-size about 4GB.
    Our database version is 9.2.0.4.0
    How I can save relational datas in a XML-File?
    Thanks in advanced
    Michael

    You can use the XMLSAXSerializer and XSU in the XDK Java package. You can use it to build SAX program to dump the result.

  • IDOC (Source) to JDA data base(thru XML files)

    hi,
         Source structure is a IDOC. I have to pass IDOC data to Function module(Z function). it will return some hierarchy levels. (For example if it's generates 12 hierarchy levels), i have to pass each hierarchy level data to one XML file.
    According to my understand source is IDOC and target is some intermediate data type. In between i am calling user defined function. it will generates the hierarchy levels and i have to pass the hierarchy level data to intermediate data type.
    this logic is correct or not?
    if this is correct how to pass data from user defined function to intermediate data type.

    Windows app should work. Web app will  not. See
    [1218745 - Chart backgrounds are not transparent when report is viewed over the web |http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes.do]
    Also below is copy of a reply to another forum thread I did on what I think is a similar issue:
    The limitation is specifically with viewing reports on the web. The trouble is that when you view a report in a web browser, we convert each graph on the report into a picture file, and display that picture in the HTML page. In this case, if you have one picture file on top of another, the top one will cover the bottom one. The only way to make it look transparent as it does in Crystal is to combine both charts into one picture. Unfortunately we don't have the ability to put two pictures into one file, that's simply one of our limitations. At this point the only work around is to export the report to PDF and view that instead.
    Ludek

Maybe you are looking for

  • Error message in pop up....

    Hi all, I want to display an error message in a pop up window , if some mandatory fields are not filled but problem is that if I am displaying the error message in the view which I am using in  pop up window that error message is also getting display

  • Can I change HREF of an image onMouseOver?

    Hi, Is there a way to mouseOver an image (A) and have DW change the HREF attribute of a different image (B)? I am trying to accomplish the following: 1. (This works now). mouseOver one of the dots in the top left and change the main image as well as

  • Read from a file list

    Hi everyone, This is the first question in this forum. I'm writing a program that capture and save several signals in different files. The files are named automatically. Now, I want make a front panel that lists all the saved files and when the user

  • Mac pro or Dual G5 2.5 GHZ

    I currently have a Imac G5 single 2.o processor and looking to get a desktop for dual screen video editing. All of my software is pre mac pro versions Final cut/Adobe After Effects - Photoshop. My question is since u have to upgrade/crossgrade to all

  • Report from Calendar

    Situation: I have a calendar folder containing employee vacation. For example employee Joe Blow has registered vacation from 2010-105-12 till 2010-10-28. How can I make Teaming to produce a report showing who has vacation registered in October 2010 a