The reason why I need to fail the task is because I am using Precedence constraints and by setting the status to Fail I can stop the control flow. However, this action raises OnError event. I expect onError event to be raised if there are any exceptions in the script not when the Results is changed to fail.
I have tried capturing the failure into a dummy script, however the OnError event is still raised.
Try putting the code that raises the error in a TRY...CATCH block, that'll stop individual lines of code from throwing errors.
I'm pretty sure though that if you set Dts.TaskResult = Dts.Results.Failure then it'll trigger an OnError event.
-Jamie
|||Failing a task is designed for signalling an error,and should not be used to drive regular (non
exceptional) control flow.
To alter control flow, a better solution is using
conditions on precedence contraints instead.
You can set some variable in the script task, then
add on-success or on-completed precedence constraint
with condition that checks that variable.
Hope this helps,
Michael [SSIS Technical Lead]|||There are better ways to stop the task without returning failure result from the script task. For example, you could have an expression on the precedence constraint that checks a variable value you set in the script for whether to go on or not.
Try that, it will solve both problems I think.
K|||I have tried setting expressions within precedence constraint and it works. But I find setting variable and changing variable's value little kludge and I am surprised that Script Task does not have a property that will fail precedence constraint without raising an error.
On the contrary end, I guess it makes sense to have script task raise an error if I set it to failure manually, since all the other tasks have similiar behaviour. That is if they fail they raise OnError event.
Thanks everyone.|||
Do you want to force a failure result without actually throwing an error? If so try the ForceExecutionResult property. It is a container property, so available on all tasks.
|||Hi
I think ive got a similar problem.
We have set up an SSIS package which goes to an FTP site and downloads files.
Everything is fine... EXCEPT (lol) when there are no files to download. This then fails the task.
However, I want the package to continue to run.
Is there away of assigning the error message given to an expression and then using the expression in the precedence contraint?
thanking you in advance
David
No comments:
Post a Comment