Create a text file output from within a procedure

I can output to a file from within SQL+ using the spool command but how do I do this from within a procedure?
I have got a table called ABC and want to output columns A and B to a new text file based on variables pased through when the procedure is run, the name of the text file should be generated from a sequence?
Any info appreciated.
Cheers
Cliff

Hi,
U can use UTL_File Package, But the only constraint is it will write the file only on the server m/c and not on the client m/c.
Regards
Gaurav

Similar Messages

  • Creating a text file output from ABAP

    Hi
    I'm trying to create a comma delimited text file by using ABAP code
    Could someone please help me with my coding in the following areas or is there better coding to do it:
    1)Is there a way  to move the entire Customer file KNA1 into my text file instead of doing it field by field.
    2)How can I do the comma seperation correctly?
    REPORT  ZTEXTFILE.
    data: lt_kna1 type table of kna1.
    data: ls_kna1 type kna1.
    data: lv_filename type string value 'ztest.txt'.
    select * from kna1 into table lt_kna1.
    open dataset lv_filename for output in text mode encoding default.
    IF sy-subrc <> 0.
      WRITE :/ 'ERROR'.
      EXIT.
    ENDIF.
    loop at lt_kna1 into ls_kna1.
    transfer ls_kna1-kunnr  to lv_filename.
    transfer ';' to lv_filename.
    transfer ls_kna1-name1 to lv_filename.
    transfer ';' to lv_filename.
    endloop.
    close dataset lv_filename.
    WRITE :/ 'DONE'.
    Many thanks
    Gerhard

    REPORT ZTEXTFILE.
    data: lt_kna1 type table of kna1,
            ls_kna1 type kna1,
            lv_filename type string value 'ztest.txt',
            lv_file type string.
    select * from kna1 into table lt_kna1.
    open dataset lv_filename for output in text mode encoding default.
    IF sy-subrc ne 0.
    WRITE :/ 'ERROR'.
    EXIT.
    else
    loop at lt_kna1 into ls_kna1.
    CONCATENATE ls_kna1-kunnr ls_kna1-name1 into lv_file separated by ','.
    transfer lv_file to lv_lilename.
    clear lv_file.
    endloop.
    close dataset lv_filename.
    endif.
    WRITE :/ 'DONE'.
    Try this out, should do the trick. Also, may i suggest not using '*' in your select statement and fetch data only for the fields you wish to have in your text file after filtering using a where Claus. It would greatly improve performance.
    Edited by: AJ Nayak on Feb 9, 2012 11:05 AM

  • Shrink file (log) from within a procedure

    I'd like to incorporate the DBCC shrinkfile command to my maintenance procedure. This procedure gets called after I've finished my weekly importing process. I only need to shrink the log files as almost all the modifications are either a record update or
    an insert (there are very few deletions done). I need to do this across several databases and for software maintainability would prefer to have only the one procedure.
    My issue is that there does not seem to be a way to point to the various databases from within a procedure to preform this operation. Also the maintenance plan modules have a shrink database operation but I don't see a shrink file operation so that doesn't
    appear to be an option.
    Have I overlooked something or is it not possible to preform a shrink file operation for the transaction log files for multiple databases?
    Developer Frog Haven Enterprises

    Thank you for your response. While I did not use your answer verbatim it did lead me to my solution as I only need to preform the shrink operation on 4 out of the 7 databases in my SQL instance.
    FYI my final solution was...
    -- shrink the log files
    DECLARE @sql
    nvarchar(500);
    SET @sql
    =
    'USE [vp]; DBCC SHRINKFILE (2, 100);';
    EXEC
    (@sql);
    SET @sql
    =
    'USE [vp_arrow]; DBCC SHRINKFILE (2, 100);';
    EXEC
    (@sql)
    Developer Frog Haven Enterprises

  • How to create a text file from jsp?

    In JSP, what is the command to create a text file and dump a variable in it?

    You mean StringBuffer?

  • HOw to create a text file in the given path and delete it after the use?

    Hi all,
    I am trying to create a text file at the given path and delete the created file after the use.
    I am using following code.:
    import java.io.*;
    // write binary data as characters
    public class RanIO {
                                            public static void main(String f[])
                                                      // First illustrate append
                                                      String lineSep = "\n";
                                                      try {
                                                                     File temp= new File("C:/Ash","cute.txt");
                                                      boolean ch=temp.createNewFile();
                                                      if(ch)
                                                           System.out.println("file created");
                                                      else
                                                      System.out.println("file Not created");
                                                      //writing to file
                                                 /*     PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter("cute.txt",true)));
                                                      p.print("Emp NO");
                                                      p.close();*/
                                                                // Open fileWriter in append mode
                                                                               FileWriter fos = new FileWriter(temp, true);
                                                                               BufferedWriter bw = new BufferedWriter(fos);
                                                                               PrintWriter pw = new PrintWriter(fos);
                                                                               double d=550;
                                                                          // lineSep = System.getProperty("line.separator");
                                                                          pw.print("Hello");
                                                                          //pw.print( lineSep );
                                                                          pw.print( d );
                                                                          pw.close();
                                  boolean det=temp.delete();
                                                 if(det)
                                                      System.out.println("File deleted");
                                                 else
                                                      System.out.println("File not deleted");
                                                 } catch (IOException ioe)
                                                                System.out.println( "Append IO error:" + ioe );
    My problem:
    1)
    I am not able to write to the file. I want to know, where i am going wrong.
    It is giving error message like
    "Canot resolve Symbol: temp,"
    But, FileWriter Constructor should accept a File type parameter.
    here temp is a file parameter.
    If i am not using file=new file();
    i can't delete the file after the use. i.e if i use
    PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter("cute.txt",true)));
    how can i delete cute.txt after the use?
    2)
    I am not able to write to the text file. file is created but, a blank file.
    "Hello" is not written into the text file.
    can anyone help me in this regard
    Thanks in advance
    Ashvini

    Thank you Ram,
    But, i want to create a text file in Append mode.
    for that i used
    FileWriter fos = new FileWriter(temp,true); But, it is not accepting FileWriter constructor in
    this format. if i use
    FileWriter fos = new
    FileWriter("c:/ash/cute.txt",true); it works fine. !!!!!Here's the javadoc
    public FileWriter(File file,
    boolean append)
    throws IOExceptionConstructs a FileWriter object given a File object. If the second argument is true, then bytes will be written to the end of the file rather than the beginning.
    Parameters:
    file - a File object to write to
    append - if true, then bytes will be written to the end of the file rather than the beginning
    Throws:
    IOException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason
    Since:
    1.4
    Are you using jdk.13 or lower ?
    >
    ONe more doubt, Does flush method deletes a file?
    if not, then i need to use
    File temp=new File("c:/ash/cute.txt");
    FileWriter fos = new FileWriter(temp,true); //which
    is again a problem
    if(temp.delete())
    out.println("File is deleted");
    }I don't know whether i am taking it wrong ! or
    anything wrong with my coding ! but, after creating
    and writing data into a text file. I must delete it
    as it contains confidential informations.
    Regards,
    Thanks.'flush' writes to a file immediately. Else you should explicitly call 'flush' to write contents from buffer to underlying source.
    javadoc again
    PrintWriter
    public PrintWriter(Writer out,
    boolean autoFlush)Create a new PrintWriter.
    Parameters:
    out - A character-output stream
    autoFlush - A boolean; if true, the println, printf, or format methods will flush the output buffer
    cheers,
    ram.
    Question; What do you gain by opening a file, writing to it and deleting it in the same program ?

  • Not able to create a text file in Client Machine using Forms 10g

    Hi - I'm mot able to create a text file in Client Machine using Forms 10g. I'm getting error when system executes the bolded line.(i.e. CLIENT_TEXT_IO.FOPEN). During run-time system is throwing "ORA-06508: PL/SQL: could not find program unit being called".
    I had attached webutil.pll in the form.
    Please advise me.
    DECLARE
    l_Temp CLIENT_TEXT_IO.FILE_TYPE;
    LC$Name Varchar2(100) ;
    LC$Fic Varchar2(100) ;
    LN$Lines Pls_integer := 0 ;
    LC$Line Varchar2(4000) ;
    Cursor C_CUR Is
    Select * From TEST_TEXTIO where rownum <= 50;
    BEGIN
    LC$Name := 'tmp_file.txt' ;
    LC$Fic := 'c:\temp\tmp_file.txt';
    Begin
    l_temp := CLIENT_TEXT_IO.FOPEN( 'C:\temp\tmp_file.txt', 'W');
    Exception
         when others then
         message( 'OPEN FILE ERROR ' || LC$Fic ||sqlerrm );
         display_error;
         raise form_trigger_failure;
    End ;
    -- Write the lines --
    For Cur In C_CUR Loop
         LC$Line := Cur.CODE || ' -> ' || Cur.COL1 || ',' || Cur.COL2 || ',' || Cur.Col3 ;
         CLIENT_TEXT_IO.PUT_LINE( LF$File, LC$Line ) ;      
         LN$Lines := C_CUR%ROWCOUNT ;
    End loop ;
    -- Close the file --
    CLIENT_TEXT_IO.FCLOSE( LF$File ) ;
    Exception
         When others Then
    message('err='||sqlerrm);message(' ');
    display_error;
    CLIENT_TEXT_IO.FCLOSE( LF$File ) ;      
         Raise ;
    END;
    Thanks.
    Arun

    Hi ,
    i have one Question though its not related to thos question if some could help me it will be really helpful,
    i have created one program to import and export excel to forms vice versa, if the form is attached with webutil its working fine am using ole2.but i have a new idea if i add this program in menu, it can be used for all the forms attched to that menu, i made program also, but problem am facing right now is if the form is not attched with webutil it will not work so is there possiblity to share my webutil from one form to another form ,so i will keep one form as a interface form in that webutil will be attched ,i can share that webutil to all other forms so that all the forms no need to attach webutil again
    if its possible means please suggest some ideas

  • "Import from Text File" & "Upload from Clipboard" icon not appearng in F110

    Hi Experts,
    While making the payment to the vendors through TN F110, in "PARAMETER" screen just next to 'STATUS' screen, there is a vendor field for selection in range and just ahead of this there is an icon for multiple vendor selection ( Bold arrow mark ). If I click on that multiple vender selection icon ( on bold arrow mark ), an another screen opens for multiple selection for vendors. In this screen 'Enter, Copy, Delete etc' icons are appearing at the bottom of the screen but "Import from Text File" & "Upload from Clipboard" icon are not appearing there.
    Can you please let me know how to bring that icons there?
    Points would be awarded.
    Rgds,
    Shailesh

    Hi Ravi,
    I have not yet created anything and have just entered the parameter. In the multiple screen for vendors there are 5 fields for individual and 5 for range selection. Even you can put more than five range selections or individual selections by clicking on the page button but there I am not finding these two icons.
    Can you please check at your end and let me know if you are getting or what to do to bring those two icons in F110.
    Rgds,
    Shailesh

  • How can I add a "Create New Text File" contextual menu?

    Hi,
    I'd like to add a "Create New Text File" contextual item. I found the "new text file" action in Automator, but I don't really know where to go from there... I want it to work on the desktop and in finder...
    Thanks

    See:
    Mac OS X Automation,
    Automated Workflow Tips,
    Introduction to Automator tutorial, and
    a four-parter on Automation in Snow Leopard by Sal Saghoian:
    Snow Leopard Services,
    Services for iPhoto,
    Safari and WebKit integration, and
    Installing and using services.
    Finally, 
    Developing AppleScript Applications and
    Apple's Automator Developer Documentation

  • How to Create a text file through Portal

    Hi,
    Is there any way to create a text file(e.g Excel file) through Portal? Thanks.
    Sumita

    I have a way to do this in VBScript, I don't know if it will work with the portal but the steps are simple. If you can create a text file within portal, try to create it as an html table:
    <table>
    <tr>
    <td>Column Header 1</td>
    <td>Column Header 2</td>
    </tr>
    <tr>
    <td>Value 1</td>
    <td>Value 2</td>
    </tr>
    <tr>
    </tr>
    </table>
    When you create this file save it with XLS extension instead of TXT, create a link to it and voila! it will load Excel and you will have your data well formatted. I found this method rather better than save the file as a CSV. You can also include any html attribute inside the <TD> or <TR> like background color and font type, Excel will keep those attributes.
    I hope this will help
    Arturo

  • How to create a text file with data.

    Hi,
    I am writing java code for testing an application, some times test can failed in some cases, I want to display an error message in text file. To that I written the code as like,
    BufferedWriter bout;
    bout =new BufferedWriter(new FileWriter("test.txt"));
    String str=”Your input data is not match with pattern”
    bout.write(str);but here it is creating a text file “ test” without any data in it.
    Can any body help that to execute the program properly
    Regards
    Buntty

    sabre150 wrote:
    JoachimSauer wrote:
    You didn't close your BufferedWriter. Since it's buffered it probably didn't write anything to the underlying file.
    Generally you must close every Writer/OutputStream that you no longer use or it won't be written reliably.It's not quite as simple as that. If you have a chain of Writers / OutputStreams then you only have to close() the outer most one since each is responsible for closing any Writer/OutputStream that it wraps. If you do decide to close them individually (a bad idea but people do do it) then you MUST close them starting from the outer most one and working to the most inner one or you will not guarantee to flush any buffered content.Of course. I might have used a misleading phrasing here. What I meant is "Every time you are done with a Writer, you must close it" and not "You must close *every* Writer that you used". Thanks for the clarification.

  • Create new text file in UTF-8 format by default

    I'm working a lot with UTF-8 text files and mainly in this format. It's becoming annoying when I have to manually save every text file as UTF-8.  After several trial-and-errors, I've made up a procedure that I've put in a blog. I think I could share
    it here for those who need it.  Hope it helps.
    http://instrumenti-meliora.blogspot.com/2014/04/create-new-text-file-in-utf-8-format-by.html

    You've made a procedure?
    Are you sure you didn't :
    Didn't what?
    https://www.google.com/#q=change+notepad+default+encoding
    Well, I'm not sure what you want me to see, but your search keywords do
    NOT make sense.  You do note change *Notepad* default encoding.  What you can change is a
    TEXT file's default encoding.
    Well, of course, if you have access to Notepad source code and you're able to change it and re-compile again, then you could really say you change Notepad's "default encoding", which I suppose would mean "default encoding every time we save".
    Why wouldn't you just provide a link (or some attribution) to the top result
    http://answers.microsoft.com/en-us/windows/forum/windows_7-windows_programs/default-utf-8-encoding-for-new-notepad-documents/525f0ae7-121e-4eac-a6c2-cfe6b498712c
    or a link to watch this done on youtube?
    http://www.youtube.com/watch?v=GnL6smxQE9k
    The title of that forum post and Youtube video is a non-sense.  New
    "Notepad" document?  Come on!  That's apparently how a newbie think what it is and it's very likely he has not a clue what it is and what he is doing.  And what if I don't use Notepad to create such file?  If I
    use UltraEdit, then mine should be "UltraEdit" document and that should be different from Notepad document, correct? LOL
    The fact that you're able to find this video would also mean you're thinking like him in that the file is really called Notepad document LOL
    For your information, that's called a text file (or document if you prefer this prettier term).  It's also called plain text file.
    Now, let's see the content of both links:
    First of all, why did they tell people to create a new text file somewhere and then
    COPY it to template folder?  That's really so dumb
    LOL  Isn't it more intelligent to create such file directly INSIDE the folder?
    Secondly, their procedures are not foolproof.  What if the Windows directory is not c:\windows?  They should tell people to open %Systemroot%\ShellNew instead.  I suppose they don't even know how this folder is called because
    nowhere is the term "template folder" ever mentioned.
    Thirdly, what if that folder doesn't work for unknown reason (which might happen in XP)?  Did they give any hint to a "failover" folder?  No, they didn't.  But I do in my procedure.
    Fourthly, they are saying as if the file name has to be "TXTUTF-8.txt", but actually we can call it whatever we like.  But smart people would have figured this out at the end.
    5 (I'd stop saying fifthly and so on LOL) I'm not sure it's necessary (or recommended) to change "fSavePageSettings" & "fSaveWindowPositions" DWORD values for Notepad as "advised" in that answer.
    As a side-note, I don't know what
    http://www.pc1news.com/saving-changes-to-notepad-configuration-1216.html is supposed to give but when I open this, I got some uTorrent warning.  Really seems like some malware webpage which tries to deceive people!
    I actually searched how a (generic) new file is created and started from there.
    So, maybe next time when you want to criticize or discredit somebody else, try to be more expert first? ;)

  • Creating large text files

    What is the fastest as well as less memory intensive way to create large files.
    Current State
    I have an application where I am reading the database and processing the information (formatting it) and using some third party API to add the information and then finally save as text file. The problem is since its third party API and we do not have any control on that and it takes very long time to generate the files
    Future state
    I want to build the file generator which will read from the database and then process/format the information one by one. Now I have following options.
    1) Add the processed information in a StringBuffer line by line and at the end of it create a file from the StringBuffer and save it.
    2) Create a custom object with different ArrayLists and keep on adding the processed lines into appropriate lists and at the end of it while saving it to a file read the custom object and save it as a file.
    3) Create a file at the start of it and then keep on adding and flushing the lines one by one and at the end of it close the file.
    For handling files I was thinking of using PrintWriter. I am talking about the text files anyware from 50 KB to 20 MB.
    I have performance concerns as well as memory issues. So I want a balanced solution so that I am able to handle both.

    Use a BufferedWriter to write each line/entry/record as you process it.
    Don't do any special flushing() (unless you need special transactional properties in which case you need a lot more than simple flush() calls).

  • How to create a text file or XML file  and add content through  code into it...

    Hi Everyone,
    How to create a text file and add content through the code to the text file eform javascript ......orelse can we create a text file in life cycle designer...
    Else say how to create a new XML file through the code and how some content like Example "Hello World".

    You can create a text file as a file attachment (data object) using the doc.createDataObject and doc.setDataObjectContents:
    http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.450.html
    http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.528.html
    You can then export the file with the doc.exportDataObject method:
    http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.463.html
    This won't work with Reader if it hasn't been given the file attachment usage right with LiveCycle Reader Extensions.

  • I was given an assingment, but have no idea where to begin. The assingment is to create a text file using notepad with all of my digital inputs and some how make those imputs show up on my digital indicators on my control pannel

    I was given an assingment, but have no idea where to begin. The assingment is to create a text file using notepad with all of my digital inputs and some how make those imputs show up on my digital indicators on my control pannel.
    When it was explained to me it didn't sound to hard of a task, I have no LabVIEW experience and the tutortial sucks.

    StevenD: FYI, I did NOT give you the one star rating. I would never do that!
    StevenD wrote:
    Ow. Someone is grumpy today.
    Well, this is an assignment, so it is probably homework.
    Why else would anyone give HIM such an assigment, after all he has no LabVIEW experience and the tutorials are too hard for him?
    This would make no sense unless all of it was just covered in class!
    This is not a free homework service with instant gratification.
    OK! Let's do it step by step. I assume you already have a VI with the digital indicators.
    "...but have no idea where to begin".
    open notepad.
    decide on a format, possibly one line per indicator.
    type the document.
    close notepad.
    open LabVIEW.
    Open the existing VI with all the indicators.
    (are you still following?)
    look at the diagram.
    Who made the program?
    Does the code make sense so far?
    Is it a statemachine or just a bunch of crisscrossed wires?
    Where do you want to add the file read?
    How should the file be read (after pressing a read button, at the start of the program ,etc.)
    See how far you get!
    Message Edited by altenbach on 06-24-2008 11:23 AM
    LabVIEW Champion . Do more with less code and in less time .

  • Function upload text file or from clipboard in Bex with BI 70

    Will it be possbile to use the function to upload data in from a text file or from clipboard with BI 70?
    With older BW versions it was possible to fill a variable with lists.
    Can someone help where I can find information about this issue?
    Best Regards, Tina

    Will it be possbile to use the function to upload data in from a text file or from clipboard with BI 70?
    With older BW versions it was possible to fill a variable with lists.
    Can someone help where I can find information about this issue?
    Best Regards, Tina

Maybe you are looking for

  • Insert and Edit NEW text not working

    hi guys, I would like to insert a new text. I thought i could use the touch-out tool but i can´t don´t know why. I did it with the typewriter tool. So the text is this now i try to change the font type but i can´t. I do not get the Typeface Menu as t

  • How to connect ITunes to my IPhone 4S ?

    I have a new Iphine 4S. I am trying to get my Itunes and phone to connect. When I downloaded Itunes all I get is the player screen. I do not get a screen that shows my Iphone connected. I have uninstalled and reinstalled ITunes 3 times and I get the

  • Black border around playlist DMP 4310

    I'm using a playlist for html assets with the DMP 4310, but they all render with a black border. Is there any way to get rid of that? EDIT: In DMS 5.3, the DMP 4310 was not able to render html, but we upgraded to 5.4 and are now able to render with t

  • 802.1x, catalyst, ACS & active directory external DB!

    Hi, I'm working with 802.1x over catalyst switch, ACS 3.1 as Radius and external DB users authentication on Ms Active Directory with LDAP. My questions are: 1) Are the only EAP's version supported by catalyst, MD5-EAP and EAP-TLS (not PEAP and LEAP);

  • Best system for FCP 7?

    Hi, I am in the position to upgrade some of my Mac components. I will be upfront at the outset and confess I have a Core i7 Hackintosh running at 3.8 GHz with a Radeon 4870 1Gb, and 12 GB of RAM. I have a 60GB SSD as a boot and app drive, plus a 1TB