Exitig a loop foreach

  • Hi guys!

    I have a forecahloop container that loops based on a variable called ListOfDates that contains a collection of dates. Inside the loop I have a dataflowtask that calls a function with the date. If the function return 0, I want to stop looping.

    Any ideas on how I can do that?

    Thanks,

    Diego

  • This is not directly supported, as far as I know.

    One thing you could try is to set an SSIS variable to 'Exit' (or whatever) and then use precedence constraints within the FEL to avoid doing any meaningful processing if user::var=="Exit".

    That way, the loop should zip round to the end pretty fast.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • Hi Phil!

    Yes I used a script and assigned the result of a "sql task" (that runs a proc) to a variable and I chec the variable. The only problem I see is that the loop doesnt actually exist, it still does the check (on the variable) the same number of times it would execute (not a big deal, but as you said, not the ideal way)

    Thanks very much for your help:-D

  • dmenin (7/7/2011)


    Hi Phil!

    Yes I used a script and assigned the result of a "sql task" (that runs a proc) to a variable and I chec the variable. The only problem I see is that the loop doesnt actually exist, it still does the check (on the variable) the same number of times it would execute (not a big deal, but as you said, not the ideal way)

    Thanks very much for your help:-D

    No problem at all.

    I agree - not ideal - but should all be happening fast and in memory.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • Another quick question!

    I just realized that my control variable is not beeing set to its original value when the loop "breaks" (I should have said that the loop I was talking about is inside another foreachLoop so I need to set it back to different than 0, which is my stop condition). How can I do that?

    Thanks

Viewing 5 posts - 1 through 4 (of 4 total)

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