通过使用表达式求值来禁用任务是否明智?

发布于 2024-11-11 17:55:09 字数 521 浏览 3 评论 0原文

我有一个 SSIS 包,计划每天导出数据。我有一些任务只想在该月的第一天执行。重要的是要跳过这些任务,并且如果不是该月的第一天,则包继续执行。

经过一番搜索后,我找到了许多参考文献来使用以下博客文章中发布的方法来解决此问题: http://bi-polar23.blogspot.com/2007/05 /conditional-task-execution.html

然而,我认为有一个更简单的解决方案。为什么我不能向每个每月第一天的任务添加一个表达式来检查该月的日期并相应地设置任务的“禁用”属性?

使用表达式和禁用任务似乎比在每个任务之前添加虚拟脚本要简单得多。还有其他人看到或知道我解决这个问题的方法有问题吗?初步测试似乎有效,但是,我发现 SSIS 很挑剔。我宁愿不做一些“非常规”的事情,如果它可能在未来引起问题。

感谢您的任何想法。

I have an SSIS Package that is scheduled to export data on a daily basis. I have a few Tasks that I'd like to execute only on the first day of the month. It is important that these Tasks are skipped, and that the Package continue to execute if it is not the first of the month.

After doing a bit of searching, I've found numerous references to solve this problem by using the method posted in the following blog post:
http://bi-polar23.blogspot.com/2007/05/conditional-task-execution.html

I think, however, there is a simpler solution. Why can't I just add an expression to each of my 1st-day-of-the-month Tasks which checks the day of the month and sets the "Disabled" property on the Task accordingly?

Using expressions and disabling the Task seems a lot simpler than adding a dummy script before each Task. Does anyone else see or know of a problem with my method for solving this problem? Preliminary tests appear to work, however, I've found SSIS to be finicky. I'd rather not do something that is "unconventional" if it might cause problems in the future.

Thanks for any thoughts.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

墨落成白 2024-11-18 17:55:09

我认为设置表达式来根据条件禁用任务没有任何非常规。我在我开发的包中做了同样的事情。我更愿意使用 Expressions 直接在任务的 Disable 属性上设置条件,而不是使用 Script Task。请参阅屏幕截图#1。换句话说,我同意你的做法。

使用此方法需要注意的是,下一个查看包的人可能不知道为什么特定任务没有在给定日期(在您的情况下是每月的第一天)执行。为了防止这种情况,您可以添加一个Annotation,指出在任务的Disable 属性上设置了一个Expression

我建议的另一件事是计算该月值的第一天并将其存储在属性 EvaluateAsExpression 设置为 true 的变量中,并在用于禁用/启用给定任务的表达式。这将阻止计算每个任务表达式中的值。屏幕截图 #1 显示 Disable 属性设置为采用变量 IsFirstDayOfMonth 中存储的值。可以设置此变量的表达式来计算该月的第一天。

希望有帮助。

屏幕截图#1:

1

I don't think there is anything unconventional about setting expressions to disable tasks on conditional basis. I have done the same thing in a package that I developed. I would prefer to set the conditions directly on the Disable property on the task using Expressions rather than using Script Task. Refer screenshot #1. In other words, I agree with your approach.

A note of caution with this approach would be that the next person looking into the package may not be aware why a particular task didn't execute on a given date (in your case first day of the month). To prevent that, you can add an Annotation stating that there is an Expression set on the Disable property of the task.

One other thing I would suggest is to calculate the first day of the month value and store it in a variable that has the property EvaluateAsExpression set to true and use this variable in the Expressions of a given task to disable\enable it. This would prevent calculating the value in each of the tasks' expressions. Screenshot #1 displays that the Disable property is set to assume the value stored in the variable IsFirstDayOfMonth. Expression on this variable can be set to calculate the first day of the month.

Hope that helps.

Screenshot #1:

1

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文