December 7, 2009 at 5:45 pm
Hello,
Using the script task I can get the name of the file being processed and pass it on to a variable.
Question:
How is it possible to start a separate task based on the name of the file?
i.e.
File being processed:
if it is "file1.csv" then execute the dataflow task 1
if it is "file2.csv" then execute the dataflow task 2
if it is "file3.csv" then execute the dataflow task 3
Thanks
December 7, 2009 at 7:19 pm
on the success/fail (so basically the conditional flow between tasks) make this based on an expression. You can make it be based on the success/failure of the previous step *and* the condition, or the condition only.
e.g. condition ==> @somevariable = "steve"
if you have 3 conditional flows, set one each for the different file names.
Steve.
December 8, 2009 at 9:09 am
Well I ftp these files from a ftp location. When I have a file named sales I want the sales related dataflow to be executed, file named finance then another dataflow task to be executed. could you be a bit more elaborate.
Thanks........
December 8, 2009 at 10:16 am
Let's say you have a package level variable (type object) that contains the ADO table of file names. Then you have a foreach container that iterates through each record in this collection (ie each file name). In that foreach container, you have an FTP Task that downloads the current file (whose name is fond in a variable, let's say currentFileName). In the foreach container, you add 3 dataflow tasks. All three are joined (come after) the FTP task.
On the precedent constraint going to dataflow task 1, doubleclick it to edit and set the Evaluation Operation of the constraint to be 'Expression and Constraint'. Leave the Value as Success. In the Expression field, enter something like @currentFileName == "File1.csv". Change the Multiple Constraints setting to 'Logical OR'. Now go to the remaining two constraints (that run to data flow tasks2 & 3) and do the same thing, except their expressions will be ' @currentFileName == "File2.csv" ' and ' @currentFileName == "File3.csv" ' respectively (note that the single quotes around the expression are *not* needed).
Now, when the foreach sets the currentFileName variable to File1.csv, the ftp task is dynamically updating (not detailed here) to download that file, and then each of the 3 constraints will be tested. In this case, the first constraint will resolve to 'true' and the first data flow task will execute. The other two will resolve to false so the remaining 2 data flow task will not execute.
HTH,
Steve.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply