How to make an XML file from SQL query on local disc (c:\temp)?

This query shows me XML results, but can I somehow make an XML file to local disc?
Thanks.
DECLARE @IMO NUMERIC(8,0)
DECLARE @Counter INT
SELECT @Counter = 1
WHILE ( @Counter <15 )
BEGIN
SET @IMO = (SELECT ImoNo from Vessel where ID=@Counter)
SELECT top 1
@IMO as ImoNumber,
VesselName,
Time,
lat as CurrentLatitude,
lon as CurrentLongitude,
sog as SpeedOverGround,
cog as CourseOverGround,
hdg as HeadingInDegrees,
GoingToCountry = (SELECT TOP 1 CountryName
FROM ShipSchedule
WHERE ImoNo = @IMO and DestPosArrived = 'false'
ORDER BY DestPosETA ),
GoingToHarbour = (SELECT TOP 1 Harbour
FROM ShipSchedule
WHERE ImoNo = @IMO and DestPosArrived = 'false'
ORDER BY DestPosETA ),
DestinationLatitude = (SELECT TOP 1 DestPosLAT
FROM ShipSchedule
WHERE ImoNo = @IMO and DestPosArrived = 'false'
ORDER BY DestPosETA ) ,
DestinationLongitude = (SELECT TOP 1 DestPosLON
FROM ShipSchedule
WHERE ImoNo = @IMO and DestPosArrived = 'false'
ORDER BY DestPosETA ),
ArrivalTime = (SELECT TOP 1 DestPosETA
FROM ShipSchedule
WHERE ImoNo = @IMO and DestPosArrived = 'false'
ORDER BY DestPosETA ),
GoingFromCountry = (SELECT TOP 1 CountryName
FROM ShipSchedule
WHERE ImoNo = @IMO and DestPosArrived = 'true'
ORDER BY DestPosETA desc),
GoingFromHarbour = (SELECT TOP 1 Harbour
FROM ShipSchedule
WHERE ImoNo = @IMO and DestPosArrived = 'true'
ORDER BY DestPosETA desc),
DepartureTime = (SELECT TOP 1 DestPosETD
FROM ShipSchedule
WHERE ImoNo = @IMO and DestPosArrived = 'true'
ORDER BY DestPosETA desc)
FROM Position
WHERE ImoNo = @IMO
order by time desc
for Xml AUTO,elements,root('SplosnaPlovba')
SELECT @Counter = @Counter + 1
END

You can use bcp with query out option
use your above query as the source query and use queryout option after specifying destination as your required local file path (specify extension as .xml)
see
http://visakhm.blogspot.com/2013/10/bcp-out-custom-format-data-to-flat-file.html
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Similar Messages

  • Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the rows? Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.

    Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the records?
    Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.

    The Oracle documentation has a good overview of the options available
    Generating XML Data from the Database
    Without knowing your version, I just picked 11.2, so you made need to look for that chapter in the documentation for your version to find applicable information.
    You can also find some information in XML DB FAQ

  • XML File from SQL Query

    I have created XML File from Query using below function:-
    select dbms_xmlgen.getxml('
    select * from tblreports where rownum<=1') from dual;
    "(CLOB) <?xml version="1.0"?>
    <ROWSET>
    <ROW>
    <REPORTID>preRES0011</REPORTID>
    <ALIAS>Date wise Summary of pins Report</ALIAS>
    <ACTIVE>Y</ACTIVE>
    <TITLE>Date wise Summary of pins Report</TITLE>
    <QUERY>select tsb.month1,
    count(SIDNUMBER)GENERATED,
    sum(case WHEN SERIALSTATUSID=&apos;SRS01&apos; THEN 1 ELSE 0 END)NotAllocated,
    SUM(CASE WHEN SERIALSTATUSID=&apos;SRS02&apos; or SERIALSTATUSID=&apos;SRS03&apos; or SERIALSTATUSID=&apos;SRS05&apos; THEN 1 ELSE 0 END)ALLOCATED,
    SUM(CASE WHEN SERIALSTATUSID=&apos;SRS02&apos; or SERIALSTATUSID=&apos;SRS01&apos; THEN 1 ELSE 0 END)NOTASSIGNEDTORESELLER,
    SUM(CASE WHEN SERIALSTATUSID=&apos;SRS03&apos; THEN 1 ELSE 0 END)READYTOACTIVATE,
    sum(CASE WHEN SERIALSTATUSID=&apos;SRS05&apos; THEN 1 ELSE 0 END)ACTIVATED,
    sum(CASE WHEN SERIALSTATUSID=&apos;SRS06&apos; THEN 1 ELSE 0 END)Terminated,
    sum(CASE WHEN SCRAPSTATUSID=&apos;CST01&apos; THEN 1 ELSE 0 END)scraped,
    sum(CASE WHEN LOCKSTATUSID=&apos;CST01&apos; THEN 1 ELSE 0 END)locked,
    NULL,
         NULL,
         NULL,
         NULL,
         NULL,
    NULL,
    NULL     
    from (SELECT TO_CHAR(CREATEDATE,&apos;DD-MON-YYYY&apos;)MONTH1 ,PINUSAGEMODEID,SERIALBATCHID,SERIALIDCOUNT,CREATEDATE FROM TBLMSERIALBATCH )TSB,
    tblmserial ts
    where TSB.SERIALBATCHID=ts.SERIALBATCHID
    and to_char(TSB.CREATEDATE,&apos;MON-YYYY&apos;)=&apos;$1&apos;
    GROUP BY TSB.MONTH1
    order by TO_DATE(MONTH1,&apos;dd-mon-yyyy&apos;) DESC</QUERY>
    <CONNECTIVITYID>C0001</CONNECTIVITYID>
    <INPUTREQUIRED>Y</INPUTREQUIRED>
    <INPUTNAME>Month</INPUTNAME>
    <CREATEDATE>30-JAN-10</CREATEDATE>
    <LASTMODIFIEDDATE>22-FEB-10</LASTMODIFIEDDATE>
    <CREATEDBY>reportadmin</CREATEDBY>
    <LASTMODIFIEDBY>reportadmin</LASTMODIFIEDBY>
    <TITLEPARAM>Y</TITLEPARAM>
    <SUBTITLE>Date wise Summary of pins Report For &amp;1</SUBTITLE>
    <ELEMENTTYPEID>AET002</ELEMENTTYPEID>
    <REPORTTYPEID>RTP01</REPORTTYPEID>
    <SORTFIELD>Disable</SORTFIELD>
    </ROW>
    </ROWSET>
    But in that it is taking '&apos;' for ' ' instead of '$1' it is taking &apos;$1&apos;
    how to keep ' ' in XML file instead of &apos?

    You can use bcp with query out option
    use your above query as the source query and use queryout option after specifying destination as your required local file path (specify extension as .xml)
    see
    http://visakhm.blogspot.com/2013/10/bcp-out-custom-format-data-to-flat-file.html
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • 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

  • How to make a jar file from a java file?

    how to make a jar file from a java file, is there any one tht can help me thank you;

    You can study this.
    http://java.sun.com/docs/books/tutorial/jar/basics/index.html

  • How to read a XML file from BLOB column and insert in a table - PL/SQL Only

    Hi,
    To make data load more simple to end user instead placing file on the server and use SQL-LOADER, I came up with new idea that using oracle ebusiness suite attachment functionality. that loads a XML file from local PC to a database column(table is fnd_attachments, default data type is BLOB over here).
    I tried with DBMS_LOB and didnt get around.
    Please can anyone tell me how to read the BLOB column using PL/SQL and store the data in a oracle table. Here's the sample XML file and table structure FYI.
    <?xml version="1.0" encoding="UTF-8"?>
    <dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Corporate_alloc.xsd" generated="2009-07-07T14:17:49">
    <Corporate_alloc>
    <PKG_CODE>BKCORP</PKG_CODE>
    <PKG_NAME>Corporate Edition - Books</PKG_NAME>
    <DET_CODE>B9780080543758</DET_CODE>
    <DET_NAME>Waves, Tides and Shallow-Water Processes</DET_NAME>
    <ALLOCATION_RATIO>0.000041</ALLOCATION_RATIO>
    </Corporate_alloc>
    <Corporate_alloc>
    <PKG_CODE>BKCORP</PKG_CODE>
    <PKG_NAME>Corporate Edition - Books</PKG_NAME>
    <DET_CODE>B9780080534343</DET_CODE>
    <DET_NAME>Hydrostatically Loaded Structures</DET_NAME>
    <ALLOCATION_RATIO>0.000127</ALLOCATION_RATIO>
    </Corporate_alloc>
    </dataroot>
    CREATE TABLE TEST_XML
    ( PKG_CODE VARCHAR2(50),
    PKG_NAME VARCHAR2(100),
    DET_CODE VARCHAR2(20),
    DET_NAME VARCHAR2(500),
    ALLOCATION_RATIO NUMBER )
    Thanks
    EBV

    In regards to #3, use the COLUMNS functionality of XMLTable instead of using Extract. Two simple examples are
    Re: XML Data - Caliculate fields
    Re: Extractvalue function not recognised

  • How to generate an xml file from a soapbody

    i'm trying to use SOAPMESSAGE from a webservice as a Datasource for my JasperReport, I'm thinking of doing it as getting the SOAPBody and saving it as xml file and setting that xml file as datasource to my JasperReport. My problem is how will a get the SOAPBody and save it as an xml file? or is there other way to make SOAP from webservice as a datasource for my Jasperreport?
    Thanks in advance for your help.

    Dear All,
    Indeed the post by RamJaddu did not answer the question. I am having the same issue: I have been provided an .xsd file which contains a data schema, and I have all of the necessary
    data in a .mdf file in order to create the required .xml file. Having queried SQL Server and received my data in "myDataSet" I can use C# to create the .xml ignoring the schema using
    string strSchemaFile = @"F:\Documents\UserCost\VictorianDataCollection\VCDCSchema_v2.xsd";
    string strXmlFile = "testXmlExport.xml";
    myDataSet.WriteXmlSchema(strSchemaFile);
    myDataSet.WriteXml(strXmlFile, XmlWriteMode.IgnoreSchema);
    but how do I export the .xml file so that is conforms with the .xsd format?
    If any of you have worked this out the answer would be most appreciated.
    All the best,
    Nick
    "Everything should be made as simple as possible, but not simpler" - Einstein

  • How to get Hierarchical XML File from a Database Join Query !

    Hi,
    How can i get a Hierarchical XML File from a Database Join Query ?
    Any join query returns repeated values as below:
    BD17:SQL>select d.dname, e.ename, e.sal
    2 from dept d
    3 natural join
    4 emp e
    5 /
    DNAME ENAME SAL
    ACCOUNTING CLARK 2450
    ACCOUNTING KING 5000
    ACCOUNTING MILLER 1300
    RESEARCH SMITH 800
    RESEARCH ADAMS 1100
    RESEARCH FORD 3000
    RESEARCH SCOTT 3000
    RESEARCH JONES 2975
    SALES ALLEN 1600
    SALES BLAKE 2850
    SALES MARTIN 1250
    SALES JAMES 950
    SALES TURNER 1500
    SALES WARD 1250
    14 rows selected.
    We tried use DBMS_XMLQUERY to generate a xml file, but it was unable to get xml in Hierarchical format.
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    - <ROWSET>
    - <ROW num="1">
    <DNAME>ACCOUNTING</DNAME>
    <ENAME>CLARK</ENAME>
    <SAL>2450</SAL>
    </ROW>
    - <ROW num="2">
    <DNAME>ACCOUNTING</DNAME>
    <ENAME>KING</ENAME>
    <SAL>5000</SAL>
    </ROW>
    - <ROW num="3">
    <DNAME>ACCOUNTING</DNAME>
    <ENAME>MILLER</ENAME>
    <SAL>1300</SAL>
    </ROW>
    - <ROW num="4">
    <DNAME>RESEARCH</DNAME>
    <ENAME>SMITH</ENAME>
    <SAL>800</SAL>
    </ROW>
    - <ROW num="5">
    <DNAME>RESEARCH</DNAME>
    <ENAME>ADAMS</ENAME>
    <SAL>1100</SAL>
    </ROW>
    - <ROW num="6">
    <DNAME>RESEARCH</DNAME>
    <ENAME>FORD</ENAME>
    <SAL>3000</SAL>
    </ROW>
    - <ROW num="7">
    <DNAME>RESEARCH</DNAME>
    <ENAME>SCOTT</ENAME>
    <SAL>3000</SAL>
    </ROW>
    - <ROW num="8">
    <DNAME>RESEARCH</DNAME>
    <ENAME>JONES</ENAME>
    <SAL>2975</SAL>
    </ROW>
    - <ROW num="9">
    <DNAME>SALES</DNAME>
    <ENAME>ALLEN</ENAME>
    <SAL>1600</SAL>
    </ROW>
    - <ROW num="10">
    <DNAME>SALES</DNAME>
    <ENAME>BLAKE</ENAME>
    <SAL>2850</SAL>
    </ROW>
    - <ROW num="11">
    <DNAME>SALES</DNAME>
    <ENAME>MARTIN</ENAME>
    <SAL>1250</SAL>
    </ROW>
    - <ROW num="12">
    <DNAME>SALES</DNAME>
    <ENAME>JAMES</ENAME>
    <SAL>950</SAL>
    </ROW>
    - <ROW num="13">
    <DNAME>SALES</DNAME>
    <ENAME>TURNER</ENAME>
    <SAL>1500</SAL>
    </ROW>
    - <ROW num="14">
    <DNAME>SALES</DNAME>
    <ENAME>WARD</ENAME>
    <SAL>1250</SAL>
    </ROW>
    </ROWSET>
    Thank you for some help.
    Nelson Alberti

    Hi,
    I wrote a general ABAP program which can be configured to grab contrent from an URL and post that content as a new PI message into the integration adapter .... from that point on normal PI configuration can be used to route it to anywhere ...
    It can be easily scheduled as a background job to grab content on a daily basis etc ...
    Regards,
    Steven

  • How to generate an XML file from SSIS (based on an XSD)?

    I have an XSD that describes an XML format. I also have a sample XML file as well from the XSD. I am trying to understand SSIS's capability to generate the XML file in an ETL process. I would need to create the XML file based on the XSD that
    I have. It is safe to assume that all the data elements are in the DB that I am incorporating in the ETL and it is also safe to assume that the data in the XML may be from multiple different tables (so massaging is probably necessary). 
    Would this be a job for C#/VB or can I do this through an SSIS process/task? Please help me understand my options. Thanks.

    Dear All,
    Indeed the post by RamJaddu did not answer the question. I am having the same issue: I have been provided an .xsd file which contains a data schema, and I have all of the necessary
    data in a .mdf file in order to create the required .xml file. Having queried SQL Server and received my data in "myDataSet" I can use C# to create the .xml ignoring the schema using
    string strSchemaFile = @"F:\Documents\UserCost\VictorianDataCollection\VCDCSchema_v2.xsd";
    string strXmlFile = "testXmlExport.xml";
    myDataSet.WriteXmlSchema(strSchemaFile);
    myDataSet.WriteXml(strXmlFile, XmlWriteMode.IgnoreSchema);
    but how do I export the .xml file so that is conforms with the .xsd format?
    If any of you have worked this out the answer would be most appreciated.
    All the best,
    Nick
    "Everything should be made as simple as possible, but not simpler" - Einstein

  • How to create an Xml File From DataBase?

    hi all
    i have two tables from my database :
    VoucherHeader and VoucherItem
     VoucherHeader has 4 fields:
    VoucherHeaderId
    bigint Unchecked
    VoucherNum bigint
    Unchecked
    VoucherDate nvarchar(50)
    Unchecked
    Comment nvarchar(50)
    Unchecked
    VoucherItem has 8 fields :
    VoucherItem bigint
    Unchecked
    VoucherHeaderRef
    bigint Unchecked
    Row bigint
    Unchecked
    Code1 bigint
    Unchecked
    Code2 bigint
    Unchecked
    ItemComment nvarchar(50)
    Unchecked
    Debit bigint
    Unchecked
    Credit bigint
    Unchecked
    and i fill datatable by this codes:
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Me.VoucherItemTableAdapter.Fill(Me.DataSet1.VoucherItem)
    Me.VoucherHeaderTableAdapter.Fill(Me.DataSet1.VoucherHeader)
    End Sub
    now i see this result:
    how to send data into an Xml File From DataGridView Header and Item?
    please help me
    thanks all.
    Name of Allah, Most Gracious, Most Merciful and He created the human

    One instruction.  But you do it from the dataset, not the DataGridView
    Me.DataSet1.WriteXml(FILENAME)
    There is a WriteXML method for a DataTable but it gives errors.  Since you dataset has two tables save bot into the same xml file.
    jdweng

  • How to export an XML file from oracle database?

    plz help me its urgent requirement....could u pls tell me the step by step procedure for following questions...?how to export a data as an XML file from oracle database?
    thanks in advance,
    Bala.
    Edited by: user3523292 on Nov 14, 2008 5:43 AM

    user3523292 wrote:
    plz help me its urgent requirement....could u pls tell me the step by step procedure for following questions...?how to export a data as an XML file from oracle database?
    thanks in advance,
    Bala.
    Edited by: user3523292 on Nov 14, 2008 5:43 AMThis is a forum of volunteers. There is no "urgent" here. Nevertheless, a google search of 'xml oracle export' quickly lead me to this Oracle site:
    otn.oracle.com/sample_code/tech/xml/index.html
    I also see lots of hits when I search the documentation library at tahiti.oracle.com for 'xml'. This one in particular may be what you are looking for:
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14252/adx_j_xsu.htm#ADXDK070

  • How to create a xml file from String object in CS4

    Hi All,
    I want to convert a string object into an XML file using Javascript in Indesign CS4.
    I have done the following script. But it does not convert the namespaces for the xml elements with no value in it.
    var xml = new XML(string);
    The value present in string is "<level_1 xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>"
    When it is converted to xml, the value becomes "<level_1 xsi:nil="true"/>"
    On processing the above xml object, am getting an error like this "Uncaught JavaScript exception: Unbound namespace prefix."
    Kindly help.
    Thanks,
    Anitha

    Can you post more of the script?
    Are you getting the XML file from disk, or a string?

  • How to transfer a (XML) file from EJB to WebDynpro / User ??

    Hello!
    Actually I'm working on an EJB which is able to generate an XML file by the data I saved before in a JDBC database.
    Now I'd like to create a WebDynpro view, from where the user can download this file (after giving the order to generate it) to his local machine.
    For the UI element FileDownload I already have inserted the binary type element into the context.
    Now I'm looking for the best way to transfer the XML file from the EJB to the view, so that it can be downloaded.
    Is it better to transfer it by DOMSource and to create the file in the view or to create the file in the EJB and transfer the binary data to the view?
    Or is there another possibility?
    Greetings,
    Ramó

    In transaction SM69 external operating system commands can be set up and then these can be executed using function SXPG_CALL_SYSTEM from ABAP or using SM49 transaction.
    See documentation in the function module and application help in the SM69 / SM49 transactions.
    You could set up commands for copy, move, delete for the relevant directories.  Be careful to limit the directories and set security appropriately.
    Andrew

  • How to read an xml file from headers

    Hi ,
    I am not getting how to read an xml file sent by client device in header to server.
    Thankx.

    There is a getHeader() in HttpServletRequest interface
    String locationURL=request.getHeader("Location");If URL of your file was set in Location attribute of header.
    Edited by: ngpgeeta on Dec 19, 2008 8:03 AM

  • Anyone know how to output an XML file from ABAP to a non sapgui location?

    I have a program that creates XML and then outputs a file via CALL METHOD cl_gui_frontend_services=>gui_download. But now I want to execute the program in background mode and therefore I need to be able to output that XML to a NON sapgui file location. Current code creates the XML to an internal table which is binary then the gui_download method converts that to output XML. .  Does anyone know how I can change the code to either a) output the XML to an internal table which can be output via, say, a TRANSFER command..or, b) output the created binary table of XML to a NON sapgui file location?
    Excerpts from current code are as follows:
    first the XML is created (to the binary file)
          Creating a ixml factory
      l_ixml = cl_ixml=>create( ).
          Creating the dom object model
      l_document = l_ixml->create_document( ).
          Fill root node with value XML
      l_element_xml  = l_document->create_simple_element(
                  name = 'XML'
                  parent = l_document ).
          Create tag 'HEADER' as child of 'XML'
      l_element_header  = l_document->create_simple_element(
                  name = 'HEADER'
                  parent = l_element_xml  ).
    header information about the file and general data about the fleet follows
      l_value = c_fleet_import.
      l_element_dummy  = l_document->create_simple_element(
                name = 'TYPE'
                value = l_value
                parent = l_element_header ).
    etc.......
    then the xml is connected to the stream factory and rendered
      Creating a stream factory
      l_streamfactory = l_ixml->create_stream_factory( ).
      Connect internal XML table to stream factory
      l_ostream = l_streamfactory->create_ostream_itable( table = l_xml_table ).
      Rendering the document
      l_renderer = l_ixml->create_renderer( ostream  = l_ostream
                                            document = l_document ).
      l_rc = l_renderer->render( ).
      Saving the XML document
      l_xml_size = l_ostream->get_num_written_raw( ).
    and then output to the file
      IF sy-subrc = 0.
        CALL METHOD cl_gui_frontend_services=>gui_download
           EXPORTING
             bin_filesize = l_xml_size
            filename     = 'g:\sapdms\BSCC-DEV\EFPAC XML Files\ALL.xml'
           filename     = '/TRICK/727/OUT/ZEFP/EFPAC.XML' "doesnt work with sap gui
             filetype     = 'BIN'
           CHANGING
             data_tab     = l_xml_table
           EXCEPTIONS
             OTHERS       = 24.
    as implied by the comments the method above will successfully output the XML file to the g:drive but will not output to /TRICK/ location, which is where I need it to go in a background mode run.
    This is a problem which has defeated all our local expertise and I would appreciate any help given... Barry Jones

    Try this code below:
    data  l_xml_table2  type table of xml_line with header line.
    W_filename - This is a Path.
      if w_filename(02) = '
        open dataset w_filename for output in binary mode.
        if sy-subrc = 0.
          l_xml_table2[] = l_xml_table[].
          loop at l_xml_table2.
            transfer l_xml_table2 to w_filename.
          endloop.
        endif.
        close dataset w_filename.
      else.
        call method cl_gui_frontend_services=>gui_download
          exporting
            bin_filesize = l_xml_size
            filename     = w_filename
            filetype     = 'BIN'
          changing
            data_tab     = l_xml_table
          exceptions
            others       = 24.
        if sy-subrc <> 0.
          message id sy-msgid type sy-msgty number sy-msgno
                     with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        endif.

Maybe you are looking for