Save query output in file

Hi,
I want to save the output of a query in a text file. I have the code to save text in a file using util_file package but i dont know how to use the same code for my query May be if i use cursors it will help but i m not getting the logic. my query is like
SELECT ACCN_PERIOD_COD_VC,SUM (op_amt_faa_nb)
FROM table1
WHERE ACCN_PERIOD_COD_VC like '%-06'
     GROUP BY ACCN_PERIOD_COD_VC
any suggestion.. thnks
Ashish

Hi,
From SQL:
SQL>SPOOL abc.txt
SQL>SELECT ACCN_PERIOD_COD_VC,SUM (op_amt_faa_nb)
FROM table1
WHERE ACCN_PERIOD_COD_VC like '%-06'
GROUP BY ACCN_PERIOD_COD_VC;
SQL>SPOOL OFF;
From PL/SQL: You will have to write cursor.
Open the Cursor.
LOOP
Fetch the record
Write into file using UTL_FILE
END LOOP
Close Cursor
Regrads

Similar Messages

  • Save report output to file

    Hi, I'm using BI publisher web service to schedule reports to email, printer, fax..etc
    How can I save report output to file? I tried both options saveOutputOption and saveDataOption but I can't find report output on the server.
    Thank you,

    option 1: bursting
    option2:
    you have to get the output, search for ReportResponse and getReportBytes,

  • CohQL command line Tool select query output in file (unix)

    Ho to insert Coherence CohQL command line Tool select query result in file in unix platform. I have tried below query but failed
    query.cmd -s -c -l "select * from 'dist-example'" >myOutput.txt
    I also tried below query, result is displayed in command line but no file is created in folder.
    select * from dist-example >myOutput.txt
    I also tried one more query, result is displayed in command line but no file is created in folder.
    select * from dist-example >/opt/bin/myOutput.txt

    Hi,
    In Unix you should use query.sh instead of query.cmd
    In your case then the command would be smething like:
    query.sh -s -c -l "select * from 'dist-example'" >myOutput.txt
    You can also try using '>>' instead of '>' in order to redirect to a text file.
    Hope this helps.
    -Cris

  • Save query output as .csv, .xls

    I am looking to save a bunch of query paramenters into a csv
    file. i am currently playing around with cffile, cfcontent,
    cfheader, but i dotn know what the best approach is. Ultimately i
    want save dialog to pop up and allow the user to save it to the
    desired location with desired name. what is the best way to do this
    in cold fusion?
    Thanks
    Drew

    Use cfheader and cfcontent to get the pop up. Use table tags
    to format your data.

  • How to save audio output to file

    Hi All,
    I'm not a flash developer, just a user, so forgive me if my
    question has misconceptions and errors.
    I've been listening to some online music that uses
    flashplayer. I'd like to be able to listen to the music offline
    and/or burn CDs of the music being streamed. I would like to know
    if there's a way to have the audio output saved to a file instead
    of being played. FYI, i'm running FP 9-beta for linux.
    Thanks.
    MickeyG2

    mickeyg2 wrote:
    > Hi All,
    >
    > I'm not a flash developer, just a user, so forgive me if
    my question has
    > misconceptions and errors.
    >
    > I've been listening to some online music that uses
    flashplayer. I'd like to
    > be able to listen to the music offline and/or burn CDs
    of the music being
    > streamed. I would like to know if there's a way to have
    the audio output saved
    > to a file instead of being played. FYI, i'm running FP
    9-beta for linux.
    Not all audio files can be saved, streaming and audio embed
    within swf files
    is hard to grab. Some players tho use directly Mp3 load,
    these files you can
    find in Internet temporary cache folder.
    For others, you could use some audio recording tool. I don't
    know Linux but windows
    has program call Total Recorder which can take any output
    your speakers play and
    record in excellent quality through your sound card device.
    Easy to use and works like charm.
    Best Regards
    Urami
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

  • Procedure to save the output of a query into excel file or flat file

    Procedure to save the output of a query into excel file or flat file
    I want to store the output of my query into a file and then export it from sql server management studio to a desired location using stored procedure.
    I have run the query --
    DECLARE @cmd VARCHAR(255)
    SET @cmd = 'bcp "select * from dbo.test1" queryout "D:\testing2.xlsx;" -U "user-PC\user" -P "" -c '
    Exec xp_cmdshell @cmd
    error message--
    SQLState = 28000, NativeError = 18456
    Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'user-PC\user'.
    NULL
    Goel.Aman

    Hello,
    -T:
    Specifies that the bcp utility connects to SQL Server with a trusted connection using integrated security. The security credentials of the network user,
    login_id, and password are not required. If
    –T is not specified, you need to specify
    –U and –P to successfully log in.
    -U:
    Specifies the login ID used to connect to SQL Server.
    Note: When the bcp utility is connecting to SQL Server with a trusted connection using integrated security, use the
    -T option (trusted connection) instead of the
    user name and password combination
    I would suggest you take a look at the following article:
    bcp Utility: http://technet.microsoft.com/en-us/library/ms162802.aspx
    A similar thread regarding this issue:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/b450937f-0ef5-427a-ae3b-115335c0d83c/bcp-connection-error-sqlstate-28000-nativeerror-18456?forum=sqldataaccess
    Regards,
    Elvis Long
    TechNet Community Support

  • Sap query output to save on application server

    Hi All,
    I have one requirement, want to save the output of sap query on application server as a text file?
    Is there any work around?
    Regards
    Vasumathi
    Edited by: komma vasumathi on Nov 5, 2009 10:32 AM

    Hi Vasumathi,
    Application server path cannot be accessed unless otherwise using OPEN DATASET. More over, Infoset cannot be executed directly. It can be accessed through SAP Query only.
    Writing Logic for 2 or 3 tables with Inner Join will not be a big deal. Writing Abap program will be optimum for you FTP requirement.
    1. create a folder in AL11 as \sap\common\
    2.  create z program and Declare sel-screen parameters : selopt1, selopt2
    3. Query : Select Afield1 Afield2 Bfield1 Bfield2 from table1 as A inner join table2 as  B on Afield1 eq Bfield1 where Afield1 in selopt1 and Afield2 in selopt2  into corresponding fields of table itab.
    4. creating file  at application sever
          w_fileloc = '\sap\common\file.txt'
         OPEN DATASET w_fileloc FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
        . Loop itab into wa_itab.
          Transfer wa_itab to w_fileloc.
         clear w_fileloc.
        endloop.
    5. goto AL11 and check the file file.txt in  folder \sap\common
    Please let me know if you need more information or close this thread by offiering the points( If you are satisfied).
    Regards,
    Sakthivel N

  • How can i save the output  of  report into  a file,.

    Hi friends,
                 i was create a executable program .. it was executing fine.. imagine.. my program is just fetching the data from  LFA1  table based on some conditions.. every thing is fine.. and i'm getting the output also..
    but i want to save this output in a separate file.. that means.. what can i do.. my program is executing background... so, i want to save this out put in a file... so, can any one plz provide me the coding steps...
    for example here i'm giving the  my program code.. so, now where can i add the new coding.. and what can  i add ...
    data:begin of  table itab occurs 0,
            lifnr  type  lifnr,
            name1 type  name1,
            end of itab.
    select lifnr  name1  from lfa1  into table  itab .
    loop at itab.
    write:/  itab-lifnr , itab-name1,
    endloop.
    i dont know coding.. I'm learning ABAP... so, can you plz provide the exact coding..for storing these data into separate file from spool..
    help ful answers will be rewarded
    Thanks
    Babu

    Hi  Santhosh,  and  Atish,
         Thanks  for ur responces... i was mention already in my question itself.. that my program is executing  in background.. so,  every day at  6 am it will execute.. but i want to see the result...
    for that what can i do..
    regards
    Babu

  • To download the query output to falt file

    Hi all,
    i have a query which i know will give more than 65k records as the output for a selection.
    i cannot run this query in excel due to its limitation.
    if i run on web i cannot download this as downloading is happening to excel file only.
    The customer ideally wants to download the query result to a text file(csv,tab-delimited etc) which inturn it will upload to MS-Access.
    How do i achieve this?
    SAP has given response use try using these options:
    1.open interfaces to receive the output of a query via the MDX language.
    2.open hub tool as it is designed for big amounts of data.(i suppose this is not possible as i want to download query output not the data target contents)
    how do i achieve my scenario with option 1?
    Are there any alternatives??
    Any useful help will be rewarded.
    Regards,
    Dhanya.

    hi vivek,
    thnks for the useful reply.
    i have some problem with my ID,hence loggin in through my coleague's ID.
    i will assign u points as i get logged in.
    I did as u said by downloading it to unconverted format.
    the file got download to a text file.where the output has
    1.header rows(10 lines almost)
    2.the values r coming in single quotes e,g:
    '144000023073      'TAAS SETTLEMENT CONV 738 '19333000   '30.09.2006          '0.000
    how can i remove all this?
    Regards,
    Dhanya
    I

  • Query Output to download in flat file through APD  or other means?

    Hello Experts,
    I am currently on BW3.5 system and have requirement to load query output in flat file in .csv format. I checked the option of APD but looks like we cant directly load the query output in flat file like in APD (BW  3.5 system) .
    One way i can think of it...load  the query output in transactional ODS and built an infospoke on it to write into flat file.
    Please advice if there are any better methods to store the query output in flat files.
    Thanks!

    Hi,
    Use RSCRM_BAPI.
    See
    Re: RSCRM_Bapi
    See the help on RSCRM_BAPI
    Re: Running Quaries automatically and saving them in as a Excel file in Server
    Re: Data transfer to external systems
    Re: Loading from a Custom R/3 Table
    Re: How can I schedule my Bex report to execute in background
    Re: How can I insert the RSCRM_BAPI into Process chain?
    Thanks
    Reddy

  • Output of SQ01 Query to a file in background

    Hello,
           I have created a SQ01 query for a certain specific outpur from my SAP system. I need to get the output of this query to a file. While i have tried executing this report from the frontend; it works smoothly, and based on the variant it creates the output and writes to a file at a remote location. But while i am trying to process the same query using background job, it creates a spool request and doesnt export the data to a file.
           Can someone please help me in getting me right in case i am doing anything wrong.
    Regards,
    V

    Hi,
    SAP have created a standard program RSTXPDFT4 to convert your Sapscripts spools into a PDF format.
    Specify the spool number and you will be able to download the sapscripts spool into your local harddisk.
    It look exactly like what you see during a spool display.
    Please note that it is not restricted to sapsciprts spool only.  Any reports in the spool can be converted using the program 'RSTXPDFT4'.
    Regards,
    Pavan

  • Query Output to CSV file

    Hi,
    I am trying to export a Query result to CSV in comma-delimited tab format.
    In SBO it is allowing to save the query results as CSV file; but when I opened
    it is in 'Text Unicode' filetype.
    Is there anyway save it directly as  CSV in comma-delimited tab format.
    Thanks Regards
    Shiva

    Hi Gordon,
    Sorry could not reply soon.
    Its a smiple query
    "SELECT ItemCode, ItemName, ItmsGrpNam,
                        LeadTime, VATLiable, CardCode"
    The things is we might make some changes to it based on customer requirement. But the fact is no matter what query, I have no problem with query. It is while saving it is making a 'tab-delimited' file rather than 'comma-delimited file'. User has to manually open it and save it as CSV file.
    Regards
    Shiva

  • Capturing the output of a jsp page and save that output in a WORD .doc file

    Hi,
    This is Naveen. I got stuck up with a problem/doubt. URGENT ! URGENT !
    My doubt is how to capture the output of a jsp page(the content is dynamic generated) and save that output to a MS-Word doc file.
    I know that therez an option of using Servlets Filters, but this concept is supported by Servlet 2.3 spec. and not earlier. And we are working on previous spec. and our web-servers also supports the prev. version and not the 2.3 version.
    If incase, therez a third-party utility for free usage, suggestions are appreciated.
    Hope most of them came across this kind of functional requirement. If anyone of them succeeded in this, please express ur bitter experience if any, faced during the coding.
    Thanks in Advance for help.
    Naveen

    You can set the MIME content type as .doc and try to open the Page.
    res.setContentType("application/vnd.ms-excel"); to generate the Page output as Excel
    res.setContentType("application/vnd.ms-word"); to generate the Page output as MS Word doc
    Hope this helps..

  • Query output transfer to excel file

    hi all,
    how can i query output transfer to excel file ? i am not using any tool. please suggest me. is there any method that i transfer that output to excel file?

    You can create a csv file. See dump_csv function from Tom Kyte.

  • ABAP Query output to XML file using Business connector

    Hi All,
    I would request your help on to know, how can I read the output of ABAP query executed in SAP system via Business connector and then generate a XML file.
    Also the existing business connector system, generates the XML file in encoding iso-8859-1. Where as customer wants the output XML file in encoding windows-1252.
    Please help with your valuable ideas.
    Thanks,

    Hello,
    possible solution:
    1. create a remote function module (FM) in SAP which returns your needed data
    2. create outbound map in BC for this FM
    3. call this FM from BC in a flow
    3. extract the result to XML (e.g. with service recordToDocument)
    CSY

Maybe you are looking for