How to write xml data to a file

Hi all,
We have a requirement of writing the xml data into a file in given directory in the server. Generating the xml data using the sql query below.
SELECT XMLELEMENT ("ROW",
XMLELEMENT ("CELL", xmlattributes ('EBIZCZMDL_01' AS "colname"), inventory_item_id),
XMLELEMENT ("CELL", xmlattributes ('EBIZFFMT_01' AS "COLNAME"), attribute29),
XMLELEMENT ("CELL", xmlattributes ('COMMON' AS "COLNAME"),inventory_item_id || '' || attribute29 || 'ITM')
AS "RESULT") "XMLDATA"
FROM apps.mtl_system_items_b
When we try to write the the data from this query to a file using UTL_FILE.put_line, the script gives the error
PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
If somebody can help us pls.......
Thanks in advance

Hi Odie,
We are looking at the xml data to be like the below:
- <xref xmlns="http://xmlns.oracle.com/xref">
- <table name="NAPP_ITEM_ITEMID">
- <columns>
<column name="EBIZFFMT_01" />
<column name="COMMON" />
<column name="EBIZQOT_01" />
<column name="EBIZCZMDL_01" />
<column name="EBIZCZGOLD_01" />
</columns>
- <rows>
- <row>
<cell colName="EBIZFFMT_01">154</cell>
<cell colName="COMMON">154811809990111362727</cell>
<cell colName="EBIZQOT_01">81</cell>
<cell colName="EBIZCZMDL_01">91</cell>
<cell colName="EBIZCZGOLD_01">991</cell>
</row>
- <row>
<cell colName="EBIZFFMT_01">180</cell>
<cell colName="COMMON">180811809990111362727</cell>
<cell colName="EBIZQOT_01">871</cell>
<cell colName="EBIZCZMDL_01">731</cell>
<cell colName="EBIZCZGOLD_01">341</cell>
</row>
</rows>
</table>
</xref>
We have managed half way trying to get the structure. As we are new to this XML Programming.
The call to dbms_xslprocessor.clob2file is within the cursor loop for the given SQL.
DECLARE
l_file_name VARCHAR2 (30);
l_file_path VARCHAR2 (200);
CURSOR xml_cur
IS
SELECT XMLELEMENT
("ROW",
XMLELEMENT ("CELL",
xmlattributes ('EBIZCZMDL_01' AS "colname"),
inventory_item_id
XMLELEMENT ("CELL",
xmlattributes ('EBIZFFMT_01' AS "COLNAME"),
attribute29
XMLELEMENT ("CELL",
xmlattributes ('COMMON' AS "COLNAME"),
inventory_item_id || '' || attribute29 || 'ITM'
) AS "RESULT"
) "XMLDATA"
FROM apps.mtl_system_items_b
WHERE attribute29 IS NOT NULL;
BEGIN
l_file_path := '/usr/tmp';
l_file_name := 'TEST_XREF4.xml';
FOR xml_rec IN xml_cur
LOOP
dbms_xslprocessor.clob2file(xml_rec.XMLDATA, l_file_path, l_file_name, nls_charset_id('UTF8') );
END LOOP;
END;
Please see the above code snippet and help us if we are doing something wrong.
Thank you

Similar Messages

  • How to read xml data in ajava file?

    Hi,
    I am very new to web servies. I am having a xml file, which has some data. I want to get tht data in my java class.How can I do tht? i would appreciate if anyone help me out.

    http://java.sun.com/webservices/docs/1.6/tutorial/doc/index.html

  • How to write binary data to browser - File Save dialog

    Hi,
    problem:
    i have a working webservice and i get binary data from that webservice.
    my dynpro java  already works and i have byte[] b which has my binary result.
    what i want:
    when the user clicks on the button, the action onActionGetResult() is executed and inside this method, the byteArray b exists. what can i do, to say the dynpro application that it should  send the binary data direct to the browser, so that the "File Save Dialog" appears and the user can save the file to the harddisk
    any ideas?

    I've found the solution:
    IWDWindow window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(
    res.getUrl(WDFileDownloadBehaviour.ALLOW_SAVE.ordinal()),
    res.getResourceName());
    window.show();
    this worked for me

  • How to write XML with attributes to a table in Oracle?

    I tried to find solutions over the internet. Some of the stuff I looked at:https://forums.oracle.com/thread/2182669 http://www.club-oracle.com/forums/how-to-insert-data-from-xml-to-table-t2845/
    In all these cases, the solution considers XML structure with only nodes and child nodes but not attributes. In fact, one of the solutions suggests transforming the XML into a canonical form with only nodes w/o attributes.
    This is a sample of xml structure I am working with:
    Sample XML
    <rep type="P" title="P List"> <as> <a id="3" /> <a id="4" /> </as> </rep>
    I am working with oracle client 11.2 and SQL developer
    My question is: how to write XML data into a table with attributes also as column values, beside the nodes?

    My question is: how to write XML data into a table with attributes also as column values, beside the nodes
    The question you should be asking is : "how do I access attributes in the XPath language?"
    and the answer to that is easily found in any XPath tutorial you may find over the Internet, it is not related to Oracle in particular.
    Short answer : you use an "attribute::" axis before the attribute name, or more commonly a "@", e.g. @type, @id etc.
    Using the method described in the first link, something like this will extract the root attributes :
    SELECT x.*
    FROM XMLTable(
           '/rep'
           passing <xmltype variable/column goes here>
           columns type  varchar2(1)  path '@type'
                 , title varchar2(30) path '@title'
    ) x ;
    For deeper levels, use additional XMLTable calls as described in the mentioned post.

  • How to write non-XML data to a file using an OSB FTP Routing?

    Hi --
    Situation ... I need to write non-XML data to a file using FTP. A proxy service retrieves XML and transforms it with XSLT to CSV format, then gives it to a Biz service to file it out, using FTP. Simple.
    Problem ... OSB sends the contents of $body to any service it calls. Because $body is a SOAP document, it has to contain XML. So therefore I have to put my CSV data into an XML element, in order to put it into $body; and this inner element then gets written to the file, which I don’t want. But if I don't enclose my CSV content in a tag, I get "Unexpected CDATA encountered" trying to assign it to a variable.
    There has to be away around this!
    Thanks for your help.
    John Taylor

    Solved. Steps:
    -- Transform the XML to CSV using an XSL transform. Put the CSV data inside enclosing XML elements, and use a Replace action to put the XML element + CSV contents back into *$body*.
    -- Define an MFL transform that only knows about the enclosing XML elements. Use a delimiter of "\n" (hard return).
    -- Route from the proxy service to a Biz service that has Service Type = Messaging Service and Request Message Type = MFL; specify the MFL transform, which will receive the incoming *$body* variable, strip off the enclosing XML element within it, and pass the CSV contents to the FTP service.
    Edited by: DunedainRanger on Nov 29, 2011 9:03 AM

  • How to store xml data into file in xml format through java program?

    HI Friends,
    Please let me know
    How to store xml data into file in xml format through java program?
    thanks......
    can discuss further at messenger.....
    Avanish Kumar Singh
    Software Engineer,
    Samsung India Development Center,
    Bangalore--560001.
    [email protected]

    Hi i need to write the data from an XML file to a Microsoft SQL SErver database!
    i got a piece of code from the net which allows me to parse th file:
    import java.io.IOException;
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    import org.apache.xerces.parsers.SAXParser;
    import java.lang.*;
    public class MySaxParser extends DefaultHandler
    private static int INDENT = 4;
    private static String attList = "";
    public static void main(String[] argv)
    if (argv.length != 1)
    System.out.println("Usage: java MySaxParser [URI]");
    System.exit(0);
    String uri = argv[0];
    try
    XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
    MySaxParser MySaxParserInstance = new MySaxParser();
    parser.setContentHandler(MySaxParserInstance);
    parser.parse(uri);
    catch(IOException ioe)
    ioe.printStackTrace();
    catch(SAXException saxe)
    saxe.printStackTrace();
    private int idx = 0;
    public void characters(char[] ch, int start, int length)
    throws SAXException
    String s = new String(ch, start, length);
    if (ch[0] == '\n')
    return;
    System.out.println(getIndent() + " Value: " + s);
    public void endDocument() throws SAXException
    idx -= INDENT;
    public void endElement(String uri, String localName, String qName) throws SAXException
    if (!attList.equals(""))
    System.out.println(getIndent() + " Attributes: " + attList);
    attList = "";
    System.out.println(getIndent() + "end document");
    idx -= INDENT;
    public void startDocument() throws SAXException
    idx += INDENT;
    public void startElement(String uri,
    String localName,
    String qName,
    Attributes attributes) throws SAXException
    idx += INDENT;
    System.out.println('\n' + getIndent() + "start element: " + localName);
    if (localName.compareTo("Machine") == 0)
    System.out.println("YES");
    if (attributes.getLength() > 0)
    idx += INDENT;
    for (int i = 0; i < attributes.getLength(); i++)
    attList = attList + attributes.getLocalName(i) + " = " + attributes.getValue(i);
    if (i < (attributes.getLength() - 1))
    attList = attList + ", ";
    idx-= INDENT;
    private String getIndent()
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < idx; i++)
    sb.append(" ");
    return sb.toString();
    }// END PRGM
    Now , am not a very good Java DEv. and i need to find a soln. to this prob within 1 week.
    The next step is to write the data to the DB.
    Am sending an example of my file:
    <Start>
    <Machine>
    <Hostname> IPCServer </Hostname>
    <HostID> 80c04499 </HostID>
    <MachineType> sun4u [ID 466748 kern.info] Sun Ultra 5/10 UPA/PCI (UltraSPARC-IIi 360MHz) </MachineType>
    <CPU> UltraSPARC-IIi at 360 MHz </CPU>
    <Memory> RAM : 512 MB </Memory>
    <HostAdapter>
    <HA> kern.info] </HA>
    </HostAdapter>
    <Harddisks>
    <HD>
    <HD1> c0t0d0 ctrl kern.info] target 0 lun 0 </HD1>
    <HD2> ST38420A 8.2 GB </HD2>
    </HD>
    </Harddisks>
    <GraphicCard> m64B : PCI PGX 8-bit +Accel. </GraphicCard>
    <NetworkType> hme0 : Fast-Ethernet </NetworkType>
    <EthernetAddress> 09:00:30:C1:34:90 </EthernetAddress>
    <IPAddress> 149.51.23.140 </IPAddress>
    </Machine>
    </Start>
    Note that i can have more than 1 machines (meaning that i have to loop thru the file to be able to write to the DB)
    Cal u tellme what to do!
    Even better- do u have a piece of code that will help me understand and implement the database writing portion?
    I badly need help here.
    THANX

  • How to read the data from Excel file and Store in XML file using java

    Hi All,
    I got a problem with Excel file.
    My problem is how to read the data from Excel file and Store in XML file using java excel api.
    For getting the data from Excel file what are all the steps i need to follow to get the correct result.
    Any body can send me the code (with java code ,Excel sheet) to this mail id : [email protected]
    Thanks & Regards,
    Sreenu,
    [email protected],
    india,

    If you want someone to do your work, please have the courtesy to provide payment.
    http://www.rentacoder.com

  • How to read and write a data from extrenal file

    Hi..
    How to read and write a data from extrenal file using Pl/sql?
    Is it possible from Dyanamic Sql or any other way?
    Reagards
    Raju

    utl_file
    Re: How to Create text(dat) file.
    Message was edited by:
    jeneesh

  • How to submit pdf xml data to a file server

    Hi, I am hoping someone can help me. I have created a dynamic pdf in livecycle designer ES, which appears as the requester wants it to. I now just need to work out how to collect the submitted data. Is it possible to submit the xml data to a file server? I have succeeded in emailing the data, but each response is separate xml attachment and would then need to collated, etc. It would be preferable to submit the data directly to a file server if this is possible. Even if it submitted into a database or something. From everything I have read so far, it seems that this is not possible, unless I am missing something. As a newbie to this, any assistance would be much appreciated. Thank you.

    You can submit the data as XML or URL-encoded data (HTTP POST). In either case you will need to have a server-side process to receive and parse the data stream. The server-side process may be a JSP, a servlet, PHP or any technology that can manage HTTP requests/responses.
    See About submitting data using a button at http://help.adobe.com/en_US/livecycle/9.0/designerHelp/000330.html .
    Steve

  • How to Read and Write .XML datas   (HELP Plz...)

    hai everybody
    how to read and write xml datas... plz give clean and simple example..
    bcoz me want to produce such type of module...
    if any one help me .. thats the only way me laid in software ladder
    plz....
    thank u in advance

    thank u for giving idiot..
    but before posting i search in google also..
    but i cant get what me expect..
    thus i posted...
    then who is ................?
    sorry javacoder01
    // plz help me
    Message was edited by:
    drvijayy2k2

  • Like to understand - Stream DataSet (of XML data) to ZIP file?

    i have similar kind of requirement where i need to save dataset data in multi part zip file. from this site i got a sample code
    .NET - Stream DataSet (of XML data) to ZIP file? but few area is not clear.
    the sample code as follows
    // get connection to the database
    var c1= new System.Data.SqlClient.SqlConnection(connstring1);
    var da = new System.Data.SqlClient.SqlDataAdapter()
    SelectCommand= new System.Data.SqlClient.SqlCommand(strSelect, c1)
    DataSet ds1 = new DataSet();
    // fill the dataset with the SELECT
    da.Fill(ds1, "Invoices");
    // write the XML for that DataSet into a zip file (split into 1mb chunks)
    using(Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile())
    zip.MaxOutputSegmentSize = 1024*1024;
    zip.AddEntry(zipEntryName, (name,stream) => ds1.WriteXml(stream) );
    zip.Save(zipFileName);
    how this word code Ionic they are using dotnet zip library ? tell me what is
    Ionic
    i guess this line zip.MaxOutputSegmentSize = 1024*1024; means each segment size would be 1mb ? am i right ?
    this line is not clear
    zip.AddEntry(zipEntryName, (name,stream) => ds1.WriteXml(stream) );
    what is the meaning of this (name,stream) stream never declared but how they can use ?
    tell me what is the meaning of this line zip.AddEntry(zipEntryName, (name,stream) => ds1.WriteXml(stream) ); what the code will do reading the above statement.
    suppose if the above code save dataset data in 5 separate zip file then what name will be used for each segment?
    if possible give me the code which will read all segment file and extract its content in a folder. thanks

    Ionic is a 3rd party library which can be download by click on the shortcut where you got the code.  I don't recommend using compiled 3rd part software unless the source code is provided.  Codeplex solutions are usually very reliable.
    Yes 1024 x 1024 is the 1mbyte size of the stream
    The library is using a Linq syntax.  So  simple Linq uses something like this
    .Select(x => x.ToString())  Where x is a variable name that can be any letter(s) you choose.  Select is part of an enumeration.  It is really just a shortcut instead of using a "FOR" statement.
    The line zip is more complicated version of Linq.  It is using two parameters (name,stream).  I don't think the code actually works and you would have to look at the documentation at the codeplex website.
    jdweng

  • Appending XML data to a file using file adaptor

    Hi,
    I am trying to append data to a file using file adaptor in XML format. (Objective is to store data as XML message in the file). I understand it is possible to append data to an existing file by making appropriate changes in WSDL manually. However, my issue is every time the XML data is appended to a file even the XML header message is also getting appended. As a result the file data does not adhere to defined schema structure anymore.
    Is there a way to save XML data in a file in append mode ?
    Thanks, Riz

    I am having the same issue as well, which makes the output XML an invalid one. I have an XSD that has a hierarchy of elements. whenever I am wiriting the child elements the header message & the name space is also getting written. For example
    <?xml version="1.0" ?><Parent xmlns="http://testSchema.com/outputSchema">
    <StartDate>01/01/2001</StartDate>
    <EndDate>01/30/2001</EndDate>
    <Child/>
    </Parent>
    <?xml version="1.0" ?><Child xmlns:ns1="http://testSchema.com/outputSchema">
    <ns1:Id>20012981</ns1:Id>
    <ns1:Value/>
    <ns1:Date>01/15/2001</ns1:Date>
    </Child>
    <?xml version="1.0" ?><Child xmlns:ns1="http://testSchema.com/outputSchema">
    <ns1:Id>20012981</ns1:Id>
    <ns1:Value/>
    <ns1:Date>01/15/2001</ns1:Date>
    </Child>
    I am using a onefile adapter partnerlink to write the parent & an another one for writing the child element, since the child elements will repeat more than once. One other way to fix this issue is write the data using java embedded activity, but that would need a lot of boiler plate code, for writing/reading/appending the same file & for handling all those IOexceptions & buffer IN/outs. I am curious if someone had the same issue & how they resolved it.

  • How to writing the data into the file at the same frequency of data acquisition using myRIO

    Hi everyone,
    I have a question regarding data acquisition fequency and data recording frequency of myRIO. Hope you guys can help me out.
    Basically, I want to acquire voltage input at analog input 0 at the frequency of 1kHz and then write the data into a file (tdms format). 
    However, I always found there were only 55 or 56 data points recorded every second in the data file (see the excel sheet). 
    To confirm my data acquisition was performed at the correct frequency, I added a small function in the main loop to indicate the time spent between two acquisition events. 
    To my surprise, the period of data acquistion is correct (1ms or 1kHz) but there are only 55 or 56 data point per second recorded in the data file.
    How can I record every data point acquired by the analog input?
    Thank you!
    P.S. I am very new to myRIO. How can I manually set the system time for myRIO? The default time of my myRIO is wrong. 
    Best,
    Tengyang
    Attachments:
    test result.xlsx ‏16 KB
    Main with timed loop.vi ‏122 KB
    test result.xlsx ‏16 KB

    Have a look at the Jakarta POI project, they have a Java API for creating Word documents.
    http://jakarta.apache.org/poi/hwpf/index.html

  • Write the data into a file in 10 ms interval within 10 sec

    Hi,
    I'm trying to write the data into a file when I press a OK button and the data should write in a file every 10ms interval. After pressing the OK button the process will stop after 10 sec.
    I've attached my VI.
    Problem is that I'm getting the result every ms. How can I get the data every 10ms? So it'll come 1000 data within 10 sec.
    For other calculations purpose I'm using Amplitude and Level Measurements block to get the mean DC voltage, so when I change the Samples to Read and Rates, the process is getting stuck.
    Any kind of suggestion is appreciable.
    Thanks,
    Chotan
    Attachments:
    DAQ_Time_Checking_For10s_02.vi ‏131 KB

    See example attached, if needed
    Nghtcwrlr
    ********************Kudos are alwayzz Welcome !! ******************
    Attachments:
    Example.vi ‏36 KB

  • How to Load the data from excel file(Extension is .CSV) into the temp.table

    Hi
    How to Load the data from excel file(Extension is .CSV) into the temporary table of oracle in Forms11g.
    My Forms Version is - Forms [64 Bit] Version 11.1.2.0.0 (Production)
    Kindly Suggest the Solution.
    Regards,
    Sachin

    Hello Sachin,
    You can use the following metalink note:How to Read Data from an EXCEL Spreadsheet into a Form Using Webutil Client_OLE2 (Doc ID 813535.1) and modify it a little bit.
    Instead of copy values into forms you can save them in your temporary table.
    Kind regards,
    Alex
    If someone's helpful or correct please mark it accordingly.

Maybe you are looking for

  • Guide for File to Soap

    HI Guys Can you please refer me to the "SOAP TO FILE scenario guide", I've been searching I can find a simple understandable guide. Thanks Yonela

  • Multiple Idoc to a file

    Hi,   I gone through the blog /people/pooja.pandey/blog/2005/07/27/idocs-multiple-types-collection-in-bpm but i am not able to understand about message mapping I am using two idoc EUPEXR.IDCREF01.ZDCREF01 and PAYEXT.PEXR2002.ZEXR2002 and I created fi

  • Recording sound on an iMac/toilet seat

    I need to record some live sound onto my iMac model M6411 (graphite toilet seat). I bought a Griffin iMic and have a wireless mic that will work with the iMic and be plugged into the USB port of the iMac. Can anyone suggest an application to use to r

  • Which API to get Annotation Authoer information?

    Hi, I read through the API document but I cannot find an API to extract the Author information. I can find PDAnnotGetTititle, PDAnnotGetSubType, PDAnnotGetDate. Is there a PDAnnotGetAuthor?

  • Photoshop cs4 trial will not intall with setup exe

    can anyone help i have downloaded the trial version of photoshop cs4 and extracted the files to an external hard drive but i cannot intall it on my computer when doulbe clicked on the setup exe file nothing happended it just opened it up and place a