FTP task when file is not found. A better way to handle....

  • I have an FTP task inside a Foreach Container. I dynamically build a collection of files to download based on date. If a particular file doesn't exist on the remote server (maybe its a weekend, etc.) the FTP task fails. I can set the FailPackageOnFailure property to false or increase the Maximum Error Count to get things to work. However what is a better way to handle the case when a file doesn't exist.

    Thanks!

    Mitch

  • This blog seems to be a better way...

    http://sqlblog.com/blogs/rushabh_mehta/archive/2008/04/24/gracefully-handing-task-error-in-ssis-package.aspx

    By setting the FTP task property ForceExecutionResult to Success and setting the Propagate system variable in the error event to false.

  • I've never actually had this problem. But you say your ForEach container is based off of date?

    Are you passing the filename from the ForEach container to your FTP task?

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

  • msmall 95832 (10/15/2010)


    This blog seems to be a better way...

    http://sqlblog.com/blogs/rushabh_mehta/archive/2008/04/24/gracefully-handing-task-error-in-ssis-package.aspx

    By setting the FTP task property ForceExecutionResult to Success and setting the Propagate system variable in the error event to false.

    I'm sure you must have noticed the precedence constraint on the faulty task 🙂

    Can you please explain the need of FTP Task in the current context. We might be able to suggest you a better package design once the requirement is clear!!:-)

    Raunak J

  • I believe the most elegant way is the following:

    use a task first to check if the necessary file is present (this can be a script task or whatever).

    Store the result in a boolean variable and then use a precedence constraint to the rest of your package with the following expression:

    @FileFound == True

    If no file is found, the first task will succeed (storing a value of false in the variable), but the rest of your package will not run.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Thanks for your replys. I think what da-zero said makes sense as far as checking to see if the file exists before downloading it.

    Specifically the file names are formatted YYYYMMDD.txt. Initially I parse out the last file name already downloaded from the previous run and extract the date. Then I populate an array variable with all the potential files to download Between the last downloaded file and todays date. So if the last file downloaded is 20101017.txt then the collection would contain 20101018.txt; 20101019.txt; 20101020.txt ...

    The for each loop enumerates the file collection variable passing in the filename to the FTP task.

    I guess when I build the file collection I should check first if the files exists before adding the filename to the collection variable. However if I'm going to do a check in a script task to see if the file exists then I might as well just download the file at that point and forget about using the FTP task?!?

  • msmall 95832 (10/19/2010)


    .... I guess when I build the file collection I should check first if the files exists before adding the filename to the collection variable. However if I'm going to do a check in a script task to see if the file exists then I might as well just download the file at that point and forget about using the FTP task?!?

    If you can do it at that point then I agree with with you. You might as well do it then and forget about the FTP tasks.



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • Mitch Small (10/19/2010)


    Thanks for your replys. I think what da-zero said makes sense as far as checking to see if the file exists before downloading it.

    Just an FYI: This is what the ForEach container can do for you if it's set up correctly. And then you don't have to worry about additional expression handling.

    EDIT: Are all the files the same initial name with just the date changing? Do they have characters in common or extensions in common? Do you want to process any and all files in a specific directory?

    If so, then you don't need to prepopulate anything or precheck anything. Just use wildcards in the ForEach container. Let me know if you need examples.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply