September 23, 2008 at 11:49 pm
Hi,
I have a folder.It contains flat files.In a foreach file container iterate all files.While doing this if any file is invalid
1.we need to ignore the error and skip that file and move to next file
2.need to catch the error file and send it to as attachment in mail task.
Any suggestions on this?
Thanks,
September 24, 2008 at 6:58 am
What defines whether or not the file is invalid?
I'm a DBA.
I'm not paid to solve problems. I'm paid to prevent them.
September 25, 2008 at 7:36 am
it differ the format like name.date.those files only allow .rest doesn't allow
Thanks,
October 8, 2008 at 10:32 am
If the files cannot be separated by the foreach loop properties (file: TheNameYouUse*.txt), you can try using a script before any other tasks within the foreach loop.
In this script, use regular expressions to check the validity of the file. If the file is invalid, set the script tasks result to failure (Dts.TaskResult = Dts.Results.Failure).
Link this script task to the next tasks by a success link: if the script task fails for a file (that is, the file is invalid), the next tasks will not be executed and the next file will be retrieved.
It's not really elegant but I did not find anything else to say 'go fetch the next file'. Let me know if you do please.
Best Regards,
Yipi.
October 12, 2008 at 5:24 am
Use a script task to validate each file. In this taks have a variable for capturing the file name and path and a boolean for indicating failed validation. Next, use an expression on the control flow (double click the control flow arrow to edit) use an expression such as @IsFileError==True you need to prefix any variables in these expressions with @.
Then have that control flow go to a file system task (this would by my approach) and move the file, using the name/path you set in the script task, to a temporary location. This way you can process all your files and at the end send the user a link to the location where the failed files live. You could also attach to email if there aren't too many.
Then you have another control flow arrow coming from the script task going to your processing steps for a valid file.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply