Procedure to write Oracle Query Result to Excel file?

Hi All,
I have a requirement to write a procedure which will write the result of a Query (select statement) to a Excel file.
I use a third party tool to do so but it fails when the query fetches more than 65000 records!
Can someone suggest me a procedure ( may be written in PL/SQL ) which can be used to achieve this task?
If there is a procedure available readily, can you please share it with me?
Thanks in advance
Himanshu Dabir

There is a ready procedure (actually PL/SQL blocks by Tom Kyte) available at
http://www.quest-pipelines.com/newsletter-v5/0704_C.htm
but it also suffers from Microsofts limitation of 65536 rows per sheet.

Similar Messages

  • How to save query result in excel file

    Hi all,
    How to save query result in excel file from sql*plus tool.
    thank you

    Do you really need an Excel file (binary) or a simple CSV?
    If you just need a CSV then search for DUMP_CSV at http://asktom.oracle.com or at this forum
    If you need formatting and/or multiple worksheets then you can use free tools like
    https://xml-spreadsheet.samplecode.oracle.com/ or https://exceldocumenttype.samplecode.oracle.com/
    Regards
    Marcus

  • Write big query results into a file  ? ?  ?

    Hi all,
    The problem is: I want to write a simple query results into a file. I have no idea how to do that. Only thing I know is utl_ functions. Please advise GURUS how can I use them for big queries. Any example will be really appreciable.
    Thank you in advance.
    Message was edited by:
    v838

    hi,
    i´ld do it like that:
    filedir     varchar2(30):= '/usr/frajo/';
    filename     varchar2(30):= 'file.txt';
    fhandle     utl_file.file_type;
    cursor x is
    select ... (what ever)
    begin
         fhandle := utl_file.fopen (filedir, filename,'a');
         open x;
         loop
              fetch x into (what ever)
              exit when x%notfound;
              utl_file.put_line (fhandle,'text and you results');
         end loop;
         utl_file.fclose(fhandle);
    end;
    happy xmas. franz

  • Select query results into excel file

    Hi,
    I want to put the results of a select query in an csv file(tab separated columns). I dont want to spool command for this . Is there any other method to do this.
    Thanks

    To get data from oracle to excel to use odbc driver to achive this.

  • Export result of ssas query result to excel file

    Hi All,
    I have browsed a SSAS cube. I want to export result of SSAS cube into excel file.
    Kindly give your input.
    Thanks,
    Vivek singh

    Hi,
    I do not know whether there is a direct solution but there is an indirect way of doing it. I always follow this method if I ever want to get MDX results into Excel.
    1 - Install the DAX Studio (I know you want MDX results, so do not get confused by looking at the word DAX. Continue reading). You can download it from the following location.
    http://www.sqlbi.com/tools/dax-studio/
    2 - Once you install DAX Studio, Go to the Add-Ins ribbon. Click on DAX Studio. 
    3 - There is an option "Tabular Server" and there is a drop-down list where you can enter the SSAS (MD CUBE Server) server name. Enter the server name manually. If you have multiple SSAS Databases and if you are interested in a specific SSAS database
    enter "Initial Catalog=Your SSAS Database Name" in Additional Options section and Click Connect. You can successfully connect to the SSAS Server now.
    Here are the details described so far in pictorial representation.
    4 - Enter your MDX manually and execute the code via DAX studio and you will get your results right-away in Excel.
    Now, isn't that an elegant way of getting MDX results into Excel :) ? Besides Excel's Pivot Table option, I do not know whether there are any alternate solutions to this but wait for other Pros' comments as well.
     Best regards...
    Chandima Lakmal Fonseka

  • Saving sql query result as excel file in different spreadsheets

    Hi,
    I have exported the output of sql into excel sheet as follow:
    SET LINESIZE 80
    SET PAGESIZE 0
    SET FEEDBACK OFF
    SET SPOOL ON
    SET TERMOUT OFF
    SPOOL current_employees.csv
    SELECT '"ID","Sales Amount","Region Id","Sales Date"' FROM dual;
    set colsep ,
    SELECT * FROM sales;
    SPOOL OFF
    But my question is how can I export SQL output in multiple excel spredsheets?
    Is there anything by which I can switch my spreadsheets through the above SQL script?
    Regards,
    Ashish

    Hi,
    I have exported the output of sql into excel sheet as follow:
    SET LINESIZE 80
    SET PAGESIZE 0
    SET FEEDBACK OFF
    SET SPOOL ON
    SET TERMOUT OFF
    SPOOL current_employees.csv
    SELECT '"ID","Sales Amount","Region Id","Sales Date"' FROM dual;
    set colsep ,
    SELECT * FROM sales;
    SPOOL OFF
    But my question is how can I export SQL output in multiple excel spredsheets?
    Is there anything by which I can switch my spreadsheets through the above SQL script?
    Regards,
    Ashish

  • Saving query results as excel

    hi,
    Is there a way to save the query results as excel programatically (some kind of utility which does the job)? we are using oracle 10g. This will be a nightly job.. so that every other day morning we have the huge excel report ready for viewing. Any help is appreciated..

    Did you think to try searching the forum? I typed in the EXACT string you used for your thread title and the first hit was ...
    Saving sql query result as excel file

  • How to save query result on the file server as excel file?

    Hi everyone,
    I need to save the the query result on the file server as excel file.
    Do you have any idees how can I do it?
    Regards
    Erwin

    i dont think you can save as excel file but you can save it as CSV use APD or RSCRM BAPI for this

  • Http 404 error exporting query result into Excel.

    Hello. I'm getting an Http 404 The webpage cannot be found" error when trying to export any APEX application's query results into Excel (Application Express 3.2.1.00.10). This was working fine before. Nothing changed with our APEX application. I've been always using I.E. Version 7.0.5730.11 with no problems. I've reset the I.E. defaults and still the problem exists. I've downloaded Mozilla Firefox and the problem does not happen. However, I would like to know why my I.E. still gets this error? Any feedback or suggestions would greatly be appreciated. Thanks for your time.

    My EI settings are as follows:
    Tools -> Internet Options -> Security
    All Three: Internet, Local Intrarnet, and Trusted Sites ... at Custom Level have the following settings:
    Downloads:
    Automatic prompting for file downloads = Enable
    File download = Enable
    Font download = Enable
    Problem still exists.
    Thanks for the help.... any additional feedback or suggestions would greatly be appreciated. Thanks for your time.

  • Step By Step Procedure to write a query

    Dear Experts,
    Can any 1 of you provide me with Snap Short of Step- by-Step , procedure to write a query.
    Thank you for your time,
    Sandy

    Ref the Link given below:
    http://www.thespot4sap.com/articles/sap_abap_queries_create_the_query.asp
    http://allaboutsap.blogspot.com/2007/09/sap-query-step-by-step.html
    Edited by: ch pavan on Mar 22, 2010 1:08 PM

  • Query results to a file

    I have a requirement to put the query result in a file(.csv),
    Pls let me know is there a possibility to achieve this using dbms_output package
    Thanks

    859486 wrote:
    I have a requirement to put the query result in a file(.csv),
    Pls let me know is there a possibility to achieve this using dbms_output packageNo. The DBMS_OUTPUT package is almost ALWAYS the wrong package to use. It is the most misunderstood and most frequently abused piece of PL/SQL software. So no - it is not suited in anyway to spool CSV output. In fact, trying it with a large SQLdataset can crash the Oracle server - as memory will be exhausted and the swap daemons will trash CPU utilisation.
    To read or write a physical o/s file - the typical package used is UTL_FILE. It is fairly easy using UTL_FILE to create a CSV file.
    However, there could be far better alternatives. The CSV file may be needed by a web client - in which case the file can be created as a CLOB and provided as a Mime text/csv data stream to a web browser (which usually will automatically open in Excel).
    The CSV file may need to be delivered via e-mail. In which case, the CSV file contents can be delivered via UTL_SMTP to a mail server as an e-mail attachment.
    The CSV file may be needed to be delivered to a remote server. In which case the CSV file can be created as a CLOB and this CLOB can be ftp'ed via PL/SQL to the remote server as a text file.
    So there are many options in creating and delivering a CSV file. Using DBMS_OUTPUT though is not a sensible option - ever.

  • Exporting data from Oracle to an existing Excel file

    Hi,
    I want to know if it is possible to open up an excel file on the server (with the necessary lay-out) and to write the query results in it?
    Another remark: the file needs to be saved under a different name (we use the user name as part of the files since the file will be sent through email rather than be displayed on the user's screen)

    If you are satisfied with a straight dump, you might want to use utl_file to make a standard CSV-file.
    If you need a little more control of the layout, you might want to check out the SYLK file format (quite ancient)
    These require no Excel application and works on UNIX servers too. If you really have to have the full magic (on a Win32 platform) you could try using Jacob or some other Java-COM-bridge to launch the Excel-application and enter the values into the worksheet but this falls into the "duct tape and chewing gum"-category of stability in my opinion...

  • Export query result to txt file

    Hello,
    I'm trying to export a query result to txt file but I facing some problems.
    I'm using the comand below:
    set echo off newpage 0 space 0 pagesize 0 feed off head off trimspool on
    set colsep ,
    spool C:\estados.txt
    select id_estado,cod_estado,nme_estado from tb_estado;
    spool off
    First problem: My select statement is being writen on my estados.txt
    Second problem: The results are being writen with a lot of blank spaces in start of line, for example, instead of write "1,AC,Acre" the line is write as " 1,AC,Acre".
    Third problem: The "spool off" statement is being written on my estados.txt
    How could I solve it?
    Thanks

    1. Works here - what version of SQL*PLUS are you using?
    2. If you want to prevent spaces, you have to write your SELECT like this:
    select id_estado || ',' || cod_estado || ',' || nme_estado from tb_estado;Note: not tested.
    3. See 1.
    C.

  • Saving query result to a file

    Hi,
    I have a sql*developer version 1.5 but i am getting a problem while saving query result to a file. When i click on "script output "-> "file icon" nothing is showing.
    Can anyboby guide me whether its a bug or some other settings are required.
    I have oracle 10.2.0.3 working on linux.
    Thanks & regards
    Girish

    I am getting the same thing and as far as I know it is a bug.
    As a workaround, you can either copy the contents of the script output or run the query as a statement (F9) instead of as a script (F5) and export the query results from the results tab.

  • Steps to save a Query/Report as Excel file in Share folder

    Hi,
    I have a requirement where i need to schedule a BI report automatically on a daily basis and save it in a Sharepoint folder as a excel file.  I have gone through the Forums but didnt get a clear idea on how to proceed this with.  I read about RSCRM_BAPI transaction but i hope we need to do this manually to save the file each time.  Also, in Broadcaster there are options only to send Email & save in Portal. 
    So, if anybody have idea on saving a Query/Report as excel file in a Share folder automatically, kindly help me in suggesting the steps to do this activity.
    Regards,
    Murali

    Hi
    1. Create Three Floders in AL11 i.e. in Apllication Server. Eg Name it F1, F2 and F3.
    2. First dump the .csv files into F1. (Name xyz.csv).
    3. Then using UNIX/WINDOWS (depends on your OS) script , first check the file is there are not in F1, if yes then rename the file with date and time or date and transfer the files from F1 to F2 i.e xyz06032010.csv.
    4. Then Create a small ABAP program to check the file in F2, if it is there then Trigger the Event, and using that event you execute teh PC.
    5. Then using UNIX/WINDOWS (depends on your OS) script , transfer the files from F2 to F3 i.e xyz06032010.csv
    6. Next day morning F1 and F2 are empty and F3 is having the backup files.
    So use this method, I used the similar logic and it is working fine.
    Timinings are importent i.e what time you need to dump the fule in F1 and what time you need to run UNIX/WINDOWS (depends on your OS) script , transfer the files from F1 to F2 and what time UNIX/WINDOWS (depends on your OS) script , transfer the files from F2 to F3.
    OR
    1. Create Two Floders in AL11 i.e. in Apllication Server. Eg Name it F1 and F2
    2. First dump the .csv files into F1. (Name xyz.csv)
    3. Then load the data using InfoPackage, through PC.
    4. At the end of the load Attach a simple Program to Move the xyz.csv file from F1 to F2.
    5. So next day the file will come to F1 and the it will load and at the end it will move to F2.
    Else  you can use simple one or two lines of UNIX/WINDOWS (depends on your OS) script to move the file from F1 to F2 , once you load is over.
    While moving the file from F1 to F2 you can append the date at the end of the file and then move to F2, it is use full for future reference.
    See Blogs and Article, similar logic...
    https://wiki.sdn.sap.com/wiki/display/profile/Surendra+Reddy
    How to transfer the Data from SAP-System to Non-SAP system without additional Cost/License
    /people/surendrakumarreddy.koduru/blog/2009/03/11/how-to-transfer-the-data-from-sap-system-to-non-sap-system-without-additional-costlicense
    To Check the Files/Reports in Application Server and Trigger Mail Alerts.
    http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/4096bf2d-bcea-2b10-4ab4-e0683830d9b2&overridelayout=true
    Thanks
    Reddy
    Edited by: Surendra Reddy on Mar 12, 2010 6:41 AM

Maybe you are looking for

  • Deletion of open lines

    Hi I must delete some lines from sales orders. The system has created delivery for most of the items in the sales orders but some items where out of stock. These are still open in the sales orders and must be deleted to prevent the system from creati

  • Message Type to Logical Systems

    Hi all, in SAP PI 7.1 I have a question for you. With transaction WE20 (into R/3 system) I find the logical system with each message type (inbound or inbound) My question is: Is there a transaction which is the contrary? That is,for a specific messag

  • My page goes beyond the fold, but no scrollbar? :S

    Hi, I have made a website in Flex, located at http://www.theplaygrounds.co.uk/The_Playground.swf Now this site is just a simple portfolio, but I have a lot planned for it. What I was wondering is that when you go to the contact page, you cannot see a

  • OS slow responding all around - please help!

    Lately my G4 is slow to respond all the way around. It click, but it doesn't; sometimes I have to click 3 or 4 times before it actually works; sometimes it works on one click. I thought it was my wireless mouse, but I changed the batteries and there

  • Facebook account adding problem

    Hi after updated Lumia amber in my Lumia 520.....facebook account was nt added in it......there shows some error code:0x85fbe195.. wts the solution to thz plm?...