Setting a loop to write a file using the UTL_FILE

I never done this using the UTL file, so I am going to ask, I need to create a file that is looks like this
H xxxxxxxxxxxx (the header same for the all file)
I Invoice Data (Information on Each account Number)
D (invoice Dtail) Detail information in each account
D
D
D
I  Invoice Data (Information on Each account Number (record 2 ) diferrent Account #n )
D (invoice Dtail) Detail information on account2
D
D
D
I  Invoice Data (Information on Each account Number (record 3 ) diferrent Account #n )
D (invoice Dtail) Detail information on account3
D
D
D
File Footer
Number on invoices
And totals I have the H the header the I (invoice Data) and D (detail) in cursors
I wonder how I can set up the loop, so the information will ended
like
The heade on top of the file, not problem here
but each
I Invoice Data
needs to have the respectively
D detail lines
I hope this is clear!!

If cursors x, y, and z map to H, I, and D in your file spec, you would need to nest the D cursor within the I cursor
FOR   x in  Invoice_data_cur
   LOOP
         utl_file.put_line(outfile,
           RPAD ('I', 2, ' ')
         ||RPAD (x.spriden_id, 9)
         ||TO_CHAR (SYSDATE, 'MM/DD/RRRR')
         ||RPAD (x.balance1, 13, '0')
           ---more stuff
   FOR  y in invoice_detail_charges_cur(x.pidm) 
         LOOP
             utl_file.put_line( outfile,
              RPAD ('D', 2, ' ')
            ||RPAD (y.spriden_id, 9)
            ||RPAD ('Previous Balance', 16, ' ')
            ||RPAD (y.stvterm_desc, 9, ' ')
            ||RPAD (TO_CHAR (SYSDATE, 'MM/DD/RRRR'), 10)
            ||RPAD (y.tbbdetc_desc, 50, ' ')
            ||LPAD(NVL (y.tbraccd_amount, '0000000000000'), 13, '0')
       for z in invoice_detail_payments_cur(x.pidm)
          LOOP
               utl_file.put_line( outfile,
                RPAD ('D', 2, ' ')
              ||RPAD (z.spriden_id, 9)
              ||RPAD ('Pending Aid ', 16, ' ')
              ||RPAD (z.STVTERM_DESC, 9, ' ')
              ||RPAD (TO_CHAR (SYSDATE, 'MM/DD/RRRR'), 10)
              ||RPAD (z.tbbdetc_desc, 50, ' ')
              ||LPAD (NVL (z.tbraccd_amount, '0000000000000'), 13, '0')
          END LOOP;      
        END LOOP;
END LOOP;From a code clarity standpoint, if your file spec uses H, I, and D as a sort of row-type identifier, I would strongly suggest that your loop variable follow that convention or spell out the row type. That is
FOR h IN Invoice_data_cur
LOOP
  <<write header>>
  FOR i IN invoice_detail_charges_cur(h.pidm)
  LOOP
    <<write invoice data>>
    FOR d IN invoice_detail_payments_cur( h.pidm )
    LOOP
      <<write invoice detail>>
    END LOOP;
  END LOOP;
END LOOP;Justin

Similar Messages

  • Write error while using the UTL_FILE.FILE_TYPE

    i get an exception 'ORA-06125 - write error' when trying to write to a flat file using utl_file.put_line function. The hint which i got out of trial and error was this 'write error' exception came out when the total character size exceeded 725-730 characters. I don't know if that is the real problem.. but when the character count is less than this.. it writes without any problem..
    Thanks in advance!!
    PK

    Try setting max_linesize in FOPEN function, for example
    p_file := utl_file.fopen( p_dir, p_filename, 'w', 4000 );
    maximum value is 32767. The default is approximately 1000 bytes.

  • How to write a file using mod pl/sql

    hi,
    i am having a submit button in my procedure. which should inturn create .sql file in a file path.
    is there any way to create a fileusing htp and htf methods.
    Thanks in advance
    Hari

    >
    i am having a submit button in my procedure. which should in turn create .sql file in a file path.
    is there any way to create a file using htp and htf methods.
    >
    Why are you wasting your time coding from scratch using the PL/SQL Web Toolkit instead of the APEX framework?
    From Re: how to write a file using mod pl/sql it appears that you are not using APEX, so a number of the approaches APEX offers are not relevant. You appear to be looking for a file download solution using the <tt>wpg_docload.download_file</tt> method, such as:
    create or replace procedure download_file (
        p_filename  in     varchar2
      , p_mimetype  in     varchar2
      , p_content   in out nocopy blob)
    is
    begin
      -- Set up HTTP header.
      -- Use "application/octet" as default MIME type.
      owa_util.mime_header(nvl(p_mimetype, 'application/octet'), false);
      -- Set the size so the browser knows how much to download.
      htp.p('Content-length: ' || dbms_lob.getlength(p_content));
      -- Filename will be used as default by the browser in "Save as..."
      htp.p('Content-Disposition: attachment; filename="' || p_filename || '"');
      -- Close header.
      owa_util.http_header_close();
      -- Stream the file content to the browser.
      wpg_docload.download_file(p_content);
    end download_file;

  • Backing up files using the label setting.

    I want to know if it is possible to back up files, using the labels setting.

    Perhaps you could adapt this script to do it...
    set itemstomovelist to choose folder with multiple selections allowed
    set listofnumbers to {}
    set err_log to {}
    if itemstomovelist is not equal to {} then
        set lst to {0, 1, 2, 3, 4, 5, 6, 7}
        repeat with i in itemstomovelist
            tell application "Finder"
                get properties of i
                set WIPCheck to (label index of the result)
                if WIPCheck is not in lst then
                    set WIPCheck to false
                end if
                if WIPCheck is not false then
                    set end of listofnumbers to WIPCheck
                    if WIPCheck = 0 then
                        -- do stuff
                    end if
                else
                    set end of err_log to ("Error - " & ((i as string) & "- Could not get Label Index/"))
                end if
            end tell
        end repeat
    end if
    return listofnumbers
    http://macscripter.net/viewtopic.php?id=24193

  • Export to PDF - Can a single report (rpt file) create multiple PDF files using the export command?

    Post Author: markeyjd2
    CA Forum: Exporting
    Greetings forum members,
    My question is, in its entirety: Can a single report (rpt file) create multiple PDF files using the export command, ideally one PDF file per DB record?
    In my case; I have a Crystal Report that reads data from a DB table containing ~ 500 records.  When I export the report to a PDF file, I get one PDF file, with ~ 500 pages.
    What I would like to do is export the report to ~ 500 individual PDF files; One file per DB record.  The file names would be based on the table's primary key.
    Is this possible?

    Post Author: Micha
    CA Forum: Exporting
    Hi,
    you need some lines of code, but its easy. Dependend on how to start the generation of your 500 PDFs, you can write an ASP page and start it via Web Browser, or a Windows Script and start it via scheduled job...
    Here's an abstract of the ASP code I use:
    First, you create a recordset (here: "rsc") which gives you the list of ID fields you want to export, then you create CrystalRuntime.Application object, then you loop through the recordset, open your report (here: "oRpt") and set login info. Then set the selectionformula, so that the report displays only the data of the current ID, e.g.:
      oRpt.RecordSelectionFormula = "(" & oRpt.RecordSelectionFormula & ") AND {myTab.myVal}=" & rsc("myVal")
    Then you export the report, move to the next record in recordset, and repeat the loop until recordset.EOF. Then you close recordset and connection.
    Micha

  • Write a file on the local system with an applet

    Hi,
    I am programming a user interface using HTML and now I would need an applet to write parameters into a plain text file.All this running on the same machine,with no network connection at all,and with I.E.
    All my attempts have failed because of security reasons,but I thought it was possible to write a file on the local machine where the applet source is.
    Can someone help me ? Please note that I am not a confirmed java user,so be as detailed as possible in your response !
    Thanks a lot !
    Sebastien

    pls go to ur jdk.13\bin and type POLICYTOOL.
    Click Add Policy Entry.
    Click Add Permission
    From the Listbox select ALLPermission and Click OK.
    Then Click Done.
    Then from the menu bar,
    File -> Save As
    then give the file name as .java.policy in ur home directory(c:\winnt\profiles\urname\.java.policy).
    close the window.
    these are the steps to give all permission.

  • Importing multiple files using the Import File menu.

    For some reason I am never able to add more the 5 mp3 files using the Import File menu. All of my files are located on the NAS device and if I select the Import Folder menu all the files in the folder will be imported. However, time after time I add more files to the same folder and then need to import just the new files to iTunes. For that I am using the Import File menu. If select more then 5 files, only 5 files will be imported. Some times I have 100 new files that I want to add, and moving 5 files a time is time consuming and painful. I try opening the folder, selecting all files and dropping them into iTunes, but that did not work. Is there a way to import more than 5 files at a time, or iTunes is not capable doing that?

    I am often surprised how many ways there are to add songs to iTunes. Selecting a number in the open file dialog must have a maximum string length for the file names. I bet that the path and file name are long on those songs and that is why you can only load 5 at a time from your NAS. What I have had luck with and is very easy is to select a group of songs and right click and "play" them. My iTunes is set to import and organize on play. The first song starts playing and they all load. I routinely do this with entire albums without problem.
    Paul

  • How to read two text files using the Read from spreadsheet.vi and then plot it

    I need to read two text files using the read from spreadsheet function and then plot these files over time.
    The file with the .res extention is the RMS values (dt and df) and the second file contains the amplitude of a frequency spectrum.
    I really appreciate any help..thanks
    Attachments:
    RMS.txt ‏1 KB
    FREQUENCY.txt ‏1 KB

    From NI Example Finder:
    Write to Text File.vi
    Read from Text File.vi
    Jean-Marc
    LV2009 and LV2013
    Free PDF Report with iTextSharp

  • Newbie question: Why is "learn sound model" greyed out when trying to remove background sounds in a file using the Spectral Frequency display?

    I am trying to remove background sounds in a file using the Spectral Frequency display. The first edit on a new file, this process works fine:
    1. use brush to cover sound
    2. right click, learn sound model
    3. effects/noise-reduction-restoration/Sound Remover
    The next time I try to remove another sound in the file, "learn sound model" is greyed out. I have to close the file and reopen to be able to make another edit. What on earth is going on? Can it only learn one sound model or something?
    I'm a newbie, so thanks in advance for your advice!

    My daughter has had her Razr for about 9 months now.  About two weeks ago she picked up her phone in the morning on her way to school when she noticed two cracks, both starting at the camera lens. One goes completely to the bottom and the other goes sharply to the side. She has never dropped it and me and my husband went over it with a fine tooth comb. We looked under a magnifying glass and could no find any reason for the glass to crack. Not one ding, scratch or bang. Our daughter really takes good care of her stuff, but we still wanted to make sure before we sent it in for repairs. Well we did and we got a reply from Motorola with a picture of the cracks saying this was customer abuse and that it is not covered under warranty. Even though they did not find any physical damage to back it up. Well I e-mailed them back and told them I did a little research and found pages of people having the same problems. Well I did not hear from them until I received a notice from Fed Ex that they were sending the phone back. NOT FIXED!!! I went to look up why and guess what there is no case open any more for the phone. It has been wiped clean. I put in the RMA # it comes back not found, I put in the ID #, the SN# and all comes back not found. Yet a day earlier all the info was there. I know there is a lot more people like me and all of you, but they just don't want to be bothered so they pay to have it fix, just to have it do it again. Unless they have found the problem and only fixing it on a customer pay only set up. I am furious and will not be recommending this phone to anyone. And to think I was considering this phone for my next up grade! NOT!!!!

  • Attempting to upload files using the zend _file_transfer system from cs5 training from the source. [was: Question for David Powers]

    I am attempting to upload files using the zend _file_transfer system from cs5 training from the source.
    On trying to upload to a remote server I am having trouble with the destination setting (C:/upload_test) in the example, please could you point me in the right direction for the an example of this setting for a remote file transfer
    Also do I have to construct a connection file to activate a Ftp file transfer?
    David Woolston

    >I am on windows platform
    Who is your host? When you checked your host path in your host control panel, what did it say?
    >i have assumed (may be incorrectly) that the purpose of the exercise was to upload to a remote site (ie my website)
    That is correct.
    >Of course that upload might take place on a computer that does not have DW installed (an internet cafe for example)
    That's irrelevant. DW is just the tool you are using to build your site. The site runs on your hosting accounts servers. This includes the php scripts you are working with.
    >I have uploaded all files necessary for the operation, when i click upload it returns no such directory exits.
    Do you have a url we can check? What destination are you specifying in zend code?
    >This made me suspect that I would need to construct a ftp file transfer connection file to satisfied username, password , connection address etc
    The exercise you are dealing with is using http file transfer. This has nothing to do with FTP. You do not need FTP for this, other than using it to move your source code from your local client to your server.

  • I am trying to create a simple animated gif in Photoshop. I've set up my frames and want to use the tween to make the transitions less jerky. When I tween between frame 1 and frame 2 the object in frame two goes out of position, appearing in a different p

    I am trying to create a simple animated gif in Photoshop. I've set up my frames and want to use the tween to make the transitions less jerky. When I tween between frame 1 and frame 2 the object in frame two goes out of position, appearing in a different place than where it is on frame 2. Confused!

    Hi Melissa - thanks for your interest. Here's the first frame, the second frame and the tween frame. I don't understand why the tween is changing the position of the object in frame 2, was expecting it to just fade from one frame to the next.

  • Load multiple files using the same data load location

    has anybody tried loading multiple files using the same load locations. I need to do this as the data in these multiple files will need to be exported from FDM as a single export file. the problem i am facing is more user related. since these files will be received at different points of time, users will need a way to tell them what has been loaded and what is yet to be loaded.
    is it possible to throw a window on the web broser with OK and Cancel buttons from an event script?
    any pointers to possible solutions will be helpful

    was able to resolve this. the implementation method is as follows
    take a back up of previously imported data in the befcleardata event script. then in the beffileimport event append the data to the import file. there are many other intricacies but this is the broad implementation logic. it allowed my users to load multiple files without worrying about append or replace import type choices

  • Is there a way to share ai or psd files using the cloud with non-cloud clients?

    I am interested in sharing the progress of a work in progress.  I have not used the cloud file storage yet and was wondering if there is a way to give clients access to a specific files using the cloud.

    Yes. Files are either Private or Public. Once a file is made Public anyone with that url can see the page for the file. You can control whether comments or dowloading of the original file is allowed.
    Your client does not need an Adobe ID to view the page, just a web browser.

  • HT4796 I have made a file using the Pages app.I mailed it to a friend.When she tried opening the same file on her pc at home , It did not open.Please help me as to how to open the file in the Microsoft word format on her pc.

    I have made a file using the Pages app.I mailed it to a friend.When she tried opening the same file on her pc at home , It did not open.Please help me as to how to open the file in the Microsoft word format on her pc.

    Send it as a PDF.

  • How do I set up my new Macbook Pro without using the annoying Voiceover?

    How do I set up my new MacBook Pro without using the annoying Voiceover?  I cannot get it to work right; it seems to get stuck and repeats the same thing over and over.  It is driving me nuts!  Is there a way to begin the setup process without using the Voiceover system?  I am a new convert from a PC and I thought a Mac was supposed to be "intuitive!" 
    Any help is appreciated.
    Thanks.
    Pamela

    There is no good reason to register your Mac anyway.
    You can opt out of the setup process and registration by pressing Command (Apple key) and the "Q" key.
    The registration process requires you to divulge a lot of unnecessary information.

Maybe you are looking for

  • "Truncation context failed to open for database" when executing Add-MailboxDatabaseCopy

    On a new two-member DAG, I'm unable to successfully create mailbox database copies.  When I issue the command: Add-MailboxDatabaseCopy -Identity TFDAG1_DB1 -MailboxServer TFEX10MB2 -ActivationPreference 2 I get the following error in Powershell: A se

  • Will iPhone 5 support WiFi calling?

    Does the iPhone 5 running IOS 8 support WiFi calling?

  • Simple (!?) CSS question

    Trying to transition to using CSS for page layout. Ran into an issue, can't figure out why. Below is the CSS for the page I'm working on: @charset "UTF-8"; /* CSS Document */ #container {      width: 968px;      margin: 0 auto;      padding-left: 10p

  • My GSM/UMTS antenna isn't working

    I have a big problem with my iPhone 4 antenna (no not the deathgrip). I think it's a hardware failure (maybe a loose connection). My phone cannot find any carrier to use, it just says "no service". I tried to recover my iPhone, and then sync the late

  • Cannot find purchase in Itune store anymore !!!

    I purchased navigation sw for Iphone , Ndrive and wanted to update to their latest version v10 but cannot find Ndrive anymore in the app store at all , please provide update , what when why how etc etc. tnx