How can I ensure that a file is only ftp-ed once?

Hi Frens,
Im at the level of testing my codes and I noticed my code deliberately ftps a file even though it has been sent. Some servers do not accept duplicate files to be sent at their servers therefore causing FTP ok at first attempt and FTP not successful at 2nd attempt with error message file already ftped.
Can someone help to advice how can I overcome this issue?
CURSOR Diebank_RRTC_Lot (pInvoiceNo varchar2,pShipTo varchar2) IS
SELECT   'D' record_id, 'DIEBANK' dept, invoiceno,
         DECODE (INSTR (MAX (d.device), '/'),
                 '0', MAX (d.device),
                 SUBSTR (MAX (d.device),
                         INSTR (MAX (d.device), '/') + 1,
                         LENGTH (MAX (d.device))
                ) part_name,
         ' ' pd_part_name, d.customerlotnumber intersil_lot_no,
         MAX (d.originalcustomerlotnumber) waferlotnumber,
         NVL (MAX (d.waferquantity), 0) wafer_quantity, MAX (mawb) mawb,
         MAX (hawb) hawb, MAX (shipfrom) from_org_code, shipto to_org_code,
         SUBSTR (MAX (invoicedate), 3, 6) ship_out_date,
         SUBSTR (MAX (invoicedate), 10, 6) ship_out_time,
         MAX (labeldatecode) datecode, MAX (d.lotobject) lotobject
FROM     fwcatns_diesinventory d, fwwiptransaction w, fwmp.proman_invoice_info@mmesp pr
   WHERE d.lotobject = w.lotobject
     AND d.asyinvoiceno = pr.invoiceno
     AND activity = 'Terminated'
     AND pr.invoiceno = pinvoiceno
     AND pr.shipto = pshipto
     AND LTRIM (d.customercode) IN ('HAT', 'HUS', 'ISL', 'ELS', 'ELX')
     AND d.state IN ('RDUMMY', 'RRTC', 'RDSCRAP')
     AND (pr.invoicedate > from_sysdate
     AND pr.invoicedate <= to_sysdate)
GROUP BY invoiceno, shipto, customerlotnumber;
CURSOR Diebank_RRTC_Lo_Filename Is
SELECT shipfrom, shipto, invoiceno
  FROM fwcatns_diesinventory d, fwmp.proman_invoice_info@mmesp p
WHERE d.asyinvoiceno = p.invoiceno
   AND d.state IN ('RDUMMY', 'RRTC', 'RDSCRAP')
   AND LTRIM (d.customercode) IN ('HAT', 'HUS', 'ISL', 'ELS', 'ELX')
   AND (invoicedate > from_sysdate
   AND invoicedate <= to_sysdate);
BEGIN
    from_sysdate := to_char(sysdate-2,'YYYYMMDD')||' 235959';
    to_sysdate := to_char(sysdate-1,'YYYYMMDD')||' 235959';
    vpath := CS_UTILS.GET_UTL_PATH ;
FOR Rec IN Diebank_RRTC_Lo_Filename  LOOP
        v_sysdate    := to_char(sysdate-1,'YYYYMMDD');
        Filename:= Rec.shipfrom||'_'||Rec.shipto||'_'||substr(v_sysdate,1,8)||'_'||Rec.invoiceno||'.txt';
        edi_hat_data := utl_file.fopen(vpath,filename,'W');
        var1 := to_char(sysdate,'YYYYMMDD HH24MISS');
        dbms_output.put_line('Start      '||var1);
        Hdr_Sql := 'H'||to_char(sysdate-1,'YYMMDD');
        utl_file.put_line(edi_hat_data,Hdr_sql);
        nRecord := '0';
FOR Lotcur IN Diebank_RRTC_Lot (Rec.InvoiceNo,Rec.ShipTo) LOOP
       SELECT MAX(lottype),SUM(componentqty) INTO vLotCode,vDieQty FROM fwlot WHERE sysid = Lotcur.Lotobject;
        IF    instr(vLotCode,'RR') > 0 OR instr(vLotCode,'CR') > 0 OR
              instr(vLotCode,'RT') > 0 OR instr(vLotCode,'RE') > 0 OR
              instr(vLotCode,'CE') > 0 OR instr(vLotCode,'RW') > 0 THEN
              vLotCode := 'REWORK';
        ELSIF (instr(vLotCode,'E') > 0 AND instr(vLotCode,'IE') = 0 AND instr(vLotCode,'PPE') = 0) OR instr(vLotCode,'Q') > 0 THEN
              vLotCode := 'ENGINEERING';
        ELSIF  instr(vLotCode,'P') > 0 OR instr(vLotCode,'IE') > 0 THEn
              vLotCode := 'PRODUCTION';
        ELSE
              vLotCode := 'PRODUCTION';
        END IF;
        Unix_Sql := rpad(LotCur.Record_Id,1,' ')||rpad(Rec.InvoiceNo,20,' ')||rpad(Lotcur.MAWB,35,' ')||rpad(NVL(Lotcur.HAWB,' '),35,' ')||
                  rpad(to_char(to_date(Lotcur.Ship_Out_Date,'YYMMDD'),'MMDDYY'),6,' ')||rpad(Lotcur.Ship_Out_Time,6,' ')||
                  rpad(Lotcur.From_Org_Code,3,' ')||
                  rpad(Lotcur.To_Org_Code,3,' ')||
                  rpad(Lotcur.Intersil_Lot_No,20,' ')||rpad(Lotcur.Dept,8,' ')||rpad(Lotcur.WaferLotNumber,20,' ')||
                  rpad(Lotcur.Part_Name,25,' ')||
                  rpad(NVL(Lotcur.PD_Part_Name,' '),25,' ')||lpad(vDieQty,10,'0')||lpad(Lotcur.Wafer_Quantity,2,'0')||
                  rpad(NVL(' ',' '),10,' ')||rpad(NVL(Lotcur.Datecode,' '),4,' ')||rpad(vLotCode,20,' ')||
                  rpad(' ',30,' ');
        utl_file.put_line(edi_hat_data,Unix_sql);
        nRecord := nRecord + 1;
END LOOP;
        Hdr_Sql := 'T'||lpad(nRecord,5,'0');
        utl_file.put_line(edi_hat_data,Hdr_sql);
        v_msg := 'Close Unix File';
        utl_file.fclose(edi_hat_data);
      filename2 := 'toftp.hattw.'||to_char(sysdate,'YYYYMMDDHH24MISS');
      edi_ftp_data  := utl_file.fopen(vpath,filename2,'W');
      Unix_Sql := '-sfile='||filename||' -ddir=/CAS/ASN -dfile='||filename||' -user=intersil\\/carsemftp -pass=40t+bqR -ip=192.157.179.7';
      Utl_File.put_line(edi_ftp_data,Unix_Sql);
      utl_file.fclose(edi_ftp_data);
      IF Rec.ShipTo = 'UNM' Then
      filename2 := 'toftp.hattws.'||to_char(sysdate,'YYYYMMDDHH24MISS');
      edi_ftp_data  := utl_file.fopen(vpath,filename2,'W');
      Unix_Sql := '-sfile='||filename||' -ddir=/home/islasn -dfile='||filename||' -user=islasn -pass=isl@usm -ip=ftp://ipohftp.unisemgroup.com';
      Utl_File.put_line(edi_ftp_data,Unix_Sql);
      utl_file.fclose(edi_ftp_data);
      ELSIF Rec.ShipTo = 'MMT' Then
      filename2 := 'toftp.hattws.'||to_char(sysdate,'YYYYMMDDHH24MISS');
      edi_ftp_data  := utl_file.fopen(vpath,filename2,'W');
      Unix_Sql := '-sfile='||filename||' -dfile='||filename||' -user=INTERSIL -pass=S4rOgoB3 -ip=thftp.m-microtech.com';
      Utl_File.put_line(edi_ftp_data,Unix_Sql);
      utl_file.fclose(edi_ftp_data);
      --this ftp not working
      ELSIF Rec.ShipTo = 'ANS' Then
      filename2 := 'toftp.hattws.'||to_char(sysdate,'YYYYMMDDHH24MISS');
      edi_ftp_data  := utl_file.fopen(vpath,filename2,'W');
      --Unix_Sql := '-sfile='||filename||' -dfile='||filename||' -user=intersilasn -pass=anst052108 -ip=58.214.241.77';
      Unix_Sql := '-sfile='||filename||' -dfile='||filename||' -user=intersilasn -pass=anst052108 -ip=58.214.5.236';
      Utl_File.put_line(edi_ftp_data,Unix_Sql);
      utl_file.fclose(edi_ftp_data);
      ELSIF Rec.ShipTo = 'CAS' Then
      filename2 := 'toftp.hattws.'||to_char(sysdate,'YYYYMMDDHH24MISS');
      edi_ftp_data  := utl_file.fopen(vpath,filename2,'W');
      Unix_Sql := '-sfile='||filename||' -dfile='||filename||' -user=intersilasn -pass=isil62nu -ip=ftp:\\192.228.215.6';
      Utl_File.put_line(edi_ftp_data,Unix_Sql);
      utl_file.fclose(edi_ftp_data);
      ELSIF Rec.ShipTo = 'SCM' Then
      filename2 := 'toftp.hattws.'||to_char(sysdate,'YYYYMMDDHH24MISS');
      edi_ftp_data  := utl_file.fopen(vpath,filename2,'W');
      Unix_Sql := '-sfile='||filename||' -ddir=/Intransit_up_folder -dfile='||filename||' -user=carsem135 -pass=Carsem -ip=203.115.242.199';
      Utl_File.put_line(edi_ftp_data,Unix_Sql);
      utl_file.fclose(edi_ftp_data);
      END IF;
END LOOP;Edited by: user11342432 on Oct 29, 2009 10:16 PM

The code looks ugly.. a lot of testing of data using PL/SQL if conditions.. why do you not use SQL for that? Why not simply join the data sets, instead of coding nested loop joins.
And why do you step outside of Oracle into the operating system?
Our system do a lot of FTPs of Oracle data - but only uses PL/SQL. Never once having to use UTL_FILE to create external files (which requires external space, external permissions, external file management, etc).
The "+file+" is create as CLOB (e.g. files=( filename varchar2(100), ..other attributes, file_content clob ) ).
This is then ftp'ed using a PL/SQL package that accepts a CLOB as file input and then ftp's it to a destination server.
Another point regarding your code - modularise. Design and build software like you would a Lego creation - using reusable blocks of code. A procedure or function should do one thing only and do it well. Not attempt to do everything and anything and clean the kitchen sink afterwards...

Similar Messages

  • How can I ensure a function is called only once in a query?

    I have a function (in a package) that returns the start date and end date to be used by my query. The query was taking bind variables but when I updated it to use the function calls it slowed down a lot.
    I tried creating an inline view that selects the start and end date and joins with the other table but this does not help. I thought the inline view would only be run once but this is not the case. I have my function print out a value from a sequence and i see that it is called thousands of times.
    Why would the procedure call be so much slower?
    How can I ensure that the function is only called once in the query?
    This is what I currently have:
    SELECT col1, col2
    FROM aTable,
    (SELECT proc.getStartdate startDate,
    proc.getEndDate endDate
    FROM dual) dt
    WHERE aTable.theDate >= dt.startDate
    AND aTable.theDate <= dt.endDate
    Thanks

    They get the begining and ending dates to be used by the query.
    My application uses the Oracle Portal. Each user can select their date range and it is stored as a user preference. The portal API provides funcitons for retrieving the preferences and I have encapsulated it in my procedure so the developers do not need knowledge of the portal. If they just restrict their queries to the dates returned by this function they will get the needed data.
    Our work around as been to pass these date variables around as bind variables.

  • How can i ensure that the time capsule back up all my data?

    how can i ensure that the time capsule back up all my data and no any data missed during the back up? becz i was backing up my mac to time capsule for the first time and it takes only 5 hourse for 279GB which is doesnt make sense
    any idea, how to ensure that all my data been backed up

    well this tells you why you are having issues.. since you have a filevault and unless you are logged on as that user TM has no way to backup the vault.
    so that is why the backup is so small.
    And you cannot remove the file vault because the disk is too small.. you are in catch 22..
    You cannot backup and you cannot remove the vault..
    Login as the user who has the file vault and copy the files off the computer to a directory on the TC.. Then just delete the files on the computer.. that will then allow you to remove the file vault.
    But never  will I ever use file vaults so I am being theoretical .. please read it up yourself.
    http://pondini.org/TM/25.html
    You are not doing the background reading you need to understand what you are doing..
    read the whole of pondini's info.. or at least skim it so you know what is there.
    Avoid like the plague file vaults..
    When disks go belly up, as they always do.. your files will be lost. Somewhere they need to be stored in the clear.. so why bother .. put better security on the computer and forget vaults.

  • How can I see that a file has been sent for workflow?

    How can I see that a file has been sent for workflow?
    During the workflow phase, the file is locked for workflow. But when the file has been approved (or denied) it will have the same status as it did before the workflow process (unless you trigger the workflow by changing its location).
    You can see the workflow history in the "My Request" view, but this way of determining whether a file has been approved seems complicated.
    Best regards
    Magnus

    Hi,
    Thanks for the transaction code, but my question is not answered yet.
    For example, I use STMS_IMPORT in the Development environement to see the list of the transport that has been made in that environement.
    I now have a list of these transports, with a status. But I wanna know if that transport that has been created in the Development environement has been moved to the Sandbox environement.
    STMS_IMPORT shows me only the list of transports that has been created in that environement. It doesn't tell me if a transport in DVL has been moved in the QAS, SANDBOX or PRODUCTION environment.
    Thanks again,
    Julien

  • Im syncing my iphone to itunes because i cant unlock the phone due to water damage so that i can take what is on it and put it on a new phone. how can i ensure that everything was taken from the phone and where can i find it in itunes?

    my phone recently suffered water damage so that the screen does not reigster when i slide to unlock. I am sycing the data from the phone onto itunes so i can put it onto a new phone. How can i ensure that i took everything off of the old phone before i restore it and where can i find all of that stuff when i sync with the new phone?

    iTunes will only store a back up of the iPhone and you find this by following the steps below:
    Windows
    Edit>Preferences>Devices
    Mac
    iTunes>Preferences>Devices
    The link below can show you what is stored in an iTunes back up:
    iTunes: About iOS backups

  • I am selling my Mac Mini. I recently purchased OS X Lion. When I restore to factory settings, how can I ensure that the operating system will still be Lion, and not the original operating system, which I believe was Snow Leopard?

    I am selling my Mac Mini. I recently purchased OS X Lion. When I restore to factory settings, how can I ensure that the operating system will still be Lion, and not the original operating system, which I believe was Snow Leopard?

    If you bought Lion from the App Store, you can't legally or practically transfer it, because it's tied to your Apple ID. Reinstall the original software from the discs that came with the machine.

  • I have iphone5 and now been given Nokia lumia 520 for work. How can I ensure that my calendars all sync in real time between each phone? Many thanks for any advice

    I have iphone5 and now been given Nokia lumia 520 for work. How can I ensure that my calendars all sync in real time between each phone? Many thanks for any advice

    Well if you got the Phone Pggray43 at a Local Corporate store in your Area)  you should be able to return it as long as you have all the contents.!  Phone, Charger and any other accessories that came with it the Box of Course.. As long as you have not went past the 14 Day return.. the store can go over what you used as in Air Time and Data..
    Now if you've went past the 14 Day return you be Liable to pay a E.T.F =  Early Termination Fee the fee for this is around $300 so hopefully you have not went past the 14 Day return window the Manager if Available is the one I would talk to tell them your on Social Security and you just can't afford a phone as this I'm sure they'll work with you to get something solved..
    Hope ya have Good Luck.! b33

  • HT204022 If I delete my photo stream photos off of my iPhone will they also delete from my photo stream on my MacBook Pro? If so how can I ensure that those photos are saved?

    If I delete my photo stream photos off of my iPhone will they also delete from my photo stream on my MacBook Pro? If so how can I ensure that those photos are saved?

    They will not be deleted if they have been imported to your iPhoto library.  To ensure this happens automatically, go to iPhoto>Preferences>iCloud and check Automatic Import:
    To confirm that they have been imported to your library, click on iCloud on the left sidebar of iPhoto, open your My Photo Stream album on the right, then Control-Click on your pictures.  If you see "Show in Library" in the pop-up, the picture has been imported to your library and you can safely delete it from photo stream.

  • How can I ensure that my IPOD files cannot be copied onto someone else's computer?

    I want to protect the files and keep others from copying the songs. How can I ensure this?

    The screen-lock passcode provides very good security to prevent what you want.  Use a non-simple passcode that can't be easily guessed.

  • In third party scenario how can we ensure that no costs go un booked?

    Dear all,
    My client is a trading company, here we have suggested a third party sales scenario without shipping notification for trading but client is asking that how can we ensure the costs of trading will not be absorbed by client. and whatever paid to vendor and fully will be collected from customer along with the profit margin.
    regards,
    Sanju..

    hi,
    ok, here we are not producing the goods to book cost of the product against it.
    you can consider this option:
    In MMR you can have the price uploaded when ever the price changes takes place and it will flow from the sales order.
    balajia

  • Both my husband and I have our Macs backed up on Time Machine. I have a new Mac and want to download my files,etc. from Timeline to my new Mac. How do I ensure that Time Machine downloads only MY files, and not my husband's files?

    Both my husband and I have our MacBook Pros backed up to Time Machine. I have a new MacBook Pro and want to download my files, etc. from Time Machine to my new Mac. I do I ensure that Time Machine downloads only MY files to my new Mac, and not my husband's files?

    OS X uses a unique identifier so there will be no problems.

  • How can i rename a jar file using only java code

    i have tried everything i can think of to accomplish this but nothing works.

    ghostbust555 wrote:
    In case you geniuses haven't realized I said I tried everything I can think of not that I tried everything. So help or shut up I realize that I didn't try everything but if you can't figure it out either DO NOT POST.
    And the question is how can i rename a jar file using java code? As it says in the title. Read.I would tell you to use the File.renameTo method, but surely that would have been obvious, and you would have tried it already? But maybe you didn't. You were kind of lacking in details in what you tried.
    And yes, I am a genius. Just don't confuse "genius" with "mind-reader".

  • How can I ensure that iTunes recognizes the correct feed?

    I'm in the process of transfering my podcast to a new website. I've been using podpress, so I had my web team enable the iTunes:New-Feed-Url option and enter the new feed url. After a week it still hadn't worked, so I uploaded one more episode to the old site hoping that would kick it over. Another week passed with no luck.
    Then I realized my team had entered the wrong url! I changed it to the correct url, and waited another week but it didn't work. I uploaded one more short file to the old site and after two days the iTunes store hasn't picked it up. I fear that somehow the iTunes store sync'd up with that incorrect url. 
    To complicate matters further, I also replaced the mp3 of the episode which appears in the store with a new mp3 telling users about the feed change. Now that episode won't download or stream throug hthe store.
    So how can I get the proper feed url synced with iTunes? How can I tell what url is currently feeding iTunes? And if that feed doesn't exist, does that mean I will need to create it and set up another iTunes:New-Feed-Url thing using podpress?
    (PS- It would be great if iTunes allowed us to simply update the url manually ourselves!)
    Link to my podcast in iTunes: https://itunes.apple.com/us/podcast/maxwell-institute-podcast/id666445688?mt=2
    Old feed: maxwellinstituteblog.org/feed/podcast
    New feed: maxwellinstitute.byu.edu/feed/podcast

    iTunes is using the feed at http://maxwellinstituteblog.org/feed/podcast/
    This does have the 'itunes:new-feed-url' tag but it reads:
    <itunes:new-feed-url>http://maxwellinstituteblog.org/feed/podcast/</itunes:new-feed-url>
    which is therefore redirecting to itself and as a result having no effect. The announcement about transferring the feed appears when subscribing but it was only posted yesterday so it's not surprising that it isn't in the Store yet. In any case you don't need it; just put the correct URL in the redirection tag and make sure to leave the original feed in place for a couple of weeks to give your subscribers plenty of time to check it. They will be transferred to the new feed and won't even notice; the Store checks feeds periodically so will transfer to the new feed on the next check. This transfer is permanent, so don't make a mistake in the URL!
    To check on the status of the feed, subscribe from the 'Subscribe' button in the Store page. Control-click (Mac) or right-click (Windows) on the title of the podcast in the 'Podcasts' section of iTunes and choose 'Copy podcast URL'.
    This will show the new feed URL if you have entered the redirection tag correctly, but it doesn't necessarily mean that the Store itself is using that feed. You will know when it does because episodes not in the old feed will show in the Store. It usually takes a couple of days or so for the Store to catch up.

  • How can I ensure that the audio sample rare of my capture preset matches?

    Hi everyone
    When capturing tapes I get warning that the audio sample rate of one or more of captured files does not match the sample rate on my source tape. This may cause the vidio and audeo of the media files to be out of sync. How can I make sure that the my capture preset matches the sample rate of my tape? Can anyone be able to show me how? Thank you. Faruk.

    Hi
    Fuerther, I have double checked and found that none of my ten projects has sound, although audio meters settings moves up & down. Simultaniously, canvas displays that in- & out of clips are not set , and in browser I see time codes on the images when the playhead stops in timeline. I did not have this problem before. I wonder appreciate if if these issues are interrelated, and if I may have clicked something that has triggered this.
    I would appreciate it if you or other friends could kindly address this problem and help me resolve the isssue. Thank you. Faruk.

  • HT3819 I have synced my ipad and iphone 5 to itunes and all my songs appear in the device library but i cannot ply all of the songs unless via home sharing. How can i ensure that my libraries appear on each device as the syncing process seems to be failin

    Syncing problems.
    How can I sync my iphone 5 and ipad to ensure that i dont need to use home sharing to access all of my music library?

    I don't think I have made myself clear... I have recently upgraded my iPhone 4 to a 5 so everything was set up to sync with no problems at all. I transferred everything across to my new device by iCloud and everything appears as it was on my old device including on the face of it my music library. However, I cannot play all of the songs in fact the majority! When at home I can access the entire library via home sharing but that is no use away from the house. I never had this problem with iPhone 4 and although I am automatically syncing the device to iTunes it is not working. If I try to play songs via the device it skips until it finds a song that cAn be played and if I try and play the device via the laptop/iTunes an ! Type signal appears and I cannot play the song!
    Any ideas re solutions would be appreciated???

Maybe you are looking for

  • Memory and dual channel problems

    Hi Can someone help me? 1- I have 2x512 MB DDR 400 Twinmos CL 2.5 and amd xp 2600 (fsb 333) and Msi K7n2 delta L. I have tested separatly my sticks, one of them woks great, if i put dram clock at 166 or 200 the sytem is always stable. The other stick

  • S.M.A.R.T. someiimes says my HD is bad other time it doesnst and sometimes...

    ... even find it ! When I use  Everest to analyse the SMART when it says my HD is bad ,  it tells me that the HD failed at the Spin Up Time test . Should I change my HD?My mobo is a K8tNeo2 FIsr

  • KKA2 values into internal table

    Hi, I would like to create a report which accepts multiple WBS elements and display with all records which comes at KKA2. KKA2 accept sinlge record, but whatever the values displaying at KKA2, i want in my Z report. Please let me know how can I fetch

  • Photoshop workflow

    i do simple daily tasks with adobe photoshop cs and i was hoping automator would make this easier. let's say i have a folder full of images. what i want automator to do for all of the images is... 1) open with photoshop 2) select-->all 3) edit-->stro

  • Exporting PCA Reports to Excel

    This question is in regards to the report: PCA Report Profit Center Grp: Plan/Actual/Variance - Tcode S_ALR_87013326. When exporting this report to a spreadsheet I'm getting different results in my development environment vs. my production environmen