Wednesday, March 7, 2012

Re-Execution of For each Loop Container

I have a For each loop container and inside the same a group of text files are loading to a table using bulk insert task.If there are duplicate files i dont wish to load it into the table. Duplicate check can be done by script task but how do i skip the files and repeat the for loop for the next files.

That means i want to skip some files and load the other files in a for loop.
How do i do that.

Can anybody please help me.

So here is what you do

Loop container has inside a Script task that checks for a duplicate file

and a BULK INSERT task that does what it says on the tin.

The script task and the BI task are joined by workflow.

Declare a variable say something like FileAlreadyThere of type DT_BOOL

(boolean)

In the script task if the file is already there set the value of this

variable to TRUE and if not then FALSE.

The workflow now between the two tasks should be based on an expression

as well as outcome so have a look at this article and you want to set

your expression to something like

@.FileAlreadyThere == FALSE

http://wiki.sqlis.com/default.aspx/SQLISWiki/LogicalOrExample.html

Allan

"Raj Amb@.discussions.microsoft.com"

wrote in message

news:1b962d72-8a6d-4b3c-bdab-e86bfda3270b@.discussions.microsoft.com:

> I have a For each loop container and inside the same a group of text

> files are loading to a table using bulk insert task.If there are

> duplicate files i dont wish to load it into the table. Duplicate check

> can be done by script task but how do i skip the files and repeat the

> for loop for the next files.

>

> That means i want to skip some files and load the other files in a for

> loop.

> How do i do that.

>

> Can anybody please help me.|||Thank you very much for your post. I would like to know one more thing that in the same for loop if the bulk load of one file fails the whole package(For loop) fails.

but i want to continue/iterate the for loop till the last file , how do i do that.|||

Raj Amb wrote:

Thank you very much for your post. I would like to know one more thing that in the same for loop if the bulk load of one file fails the whole package(For loop) fails.

but i want to continue/iterate the for loop till the last file , how do i do that.


This is controlled by two properties:
1) FailPackageOnFailure on each task or container - set it to false to ignore errors.
2) Also, each task and container have MaxErrorCount - increase it to desired value.

No comments:

Post a Comment