SSIS:如果条件满足则执行第一个任务,否则跳到下一个 [英] SSIS: execute first task if condition met else skip to next

查看:43
本文介绍了SSIS:如果条件满足则执行第一个任务,否则跳到下一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始了解 SSIS,如果问题太简单,我深表歉意.

I am getting to know SSIS, I apologize if the question is too simple.

我在 foreach-loop-容器中有一组任务.
第一个任务只需要在条件某个用户变量不为空或不为空的情况下执行.
否则,流程应该跳过第一个任务并继续执行第二个任务.

I got a set of tasks inside a foreach-loop-container.
The first task needs only to get executed on condition that a certain user variable is not null or empty.
Otherwise, the flow should skip the first task and continue to the second one.

我将如何(详细地)实现这一点?

How would I go about realizing this (in detail) ?

推荐答案

问题 1:有两种方法可以解释您的逻辑:...某个用户变量不为 null 或为空":

Issue 1: There are two ways to interpret your logic: "...a certain user variable is not null or empty":

  1. (变量不为空)或(变量为空).
  2. (变量不为空)或(变量不为空).

  1. The (Variable is Not Null) OR the (Variable is Empty).
  2. The (Variable is Not Null) OR the (Variable is Not Empty).

这完全是关于not"这个词的对象.这些差异很细微,但会影响 Foreach 循环中第一个任务的执行时间.出于演示目的,我假设您打算 #1.

It's all about the object(s?) of the word "not". The differences are subtle but will impact when the first task in the Foreach loop executes. For demonstration purposes, I am assuming you intend #1.

问题 2:第一个任务不再是第一个.为了在 BIDS 环境中使用 SSIS 完成您希望完成的任务,您需要在以前称为第一个任务"的任务之前放置另一个任务提前.这样您就可以对新的第一个任务中的前一个任务设置优先约束.可以通过从托管代码动态设计 SSIS 来实现您的愿望,但我认为这个问题不能保证与该设计选择相关的开销.我喜欢使用一个空的 Sequence Container 作为锚"任务 - 一个单独存在的任务作为优先约束的起始端点.我大量记录了它们.我不希望任何人删除不必要的空容器"并在大厅里徘徊几天摇头并重复安迪,安迪,安迪......"但我离题了.

Issue 2: The first task can no longer be first. In order to accomplish what you desire using SSIS inside the BIDS environment, you need to place another task ahead of the task formerly known as "the first task". This is so you can set a Precedence Constraint on the former first task from the new first task. It is possible to accomplish what you desire by designing your SSIS dynamically from managed code, but I don't think this issue warrants the overhead associated with that design choice. I like using an empty Sequence Container as an "Anchor" task - a task that exists solely to serve as the starting endpoint of a Precedence Constraint. I heavily document them as such. I don't want anyone deleting the "unnecessary empty container" and roaming the halls for days shaking their heads and repeating "Andy, Andy, Andy..." but I digress.

在下面的示例中,我有两个优先约束留下空的序列容器.一个转到可以跳过的任务,另一个转到有时可以跳过的任务之后的任务.在有时可以跳过的任务和随后的任务之间需要第三个优先约束.需要注意的是,必须编辑这第三个优先约束并将 Multiple Constraints 选项设置为 OR.这允许在采用任一互斥的先前路径时执行后续任务.默认情况下,这被设置为 AND 并且需要 both 路径来执行.根据定义,这不会 - 不能不会 - 在互斥路径中发生.

In the example below, I have two precedence constraints leaving the empty Sequence Container. One goes to the task that may be skipped and the other to the task following the task that can sometimes be skipped. A third precedence constraint is required between the task that can sometimes be skipped and the task following. It is important to note this third precedence constraint must be edited and the Multiple Constraints option set to OR. This allows the task following to execute when either of the mutually exclusive previous paths are taken. By default, this is set to AND and will require both paths to execute. By definition, that will not - cannot - happen with mutually exclusive paths.

我测试了一个名为@MyVar 的 SSIS 字符串变量的值,看看它是 Null 还是 Empty.对于离开空序列容器的约束,我使用了仅表达式评估选项.表达方式各不相同,但建立了表达方式的互斥性.我的 Foreach 循环容器如下所示:

I test the value of an SSIS String variable named @MyVar to see if it's Null or Empty. I used the Expression Only Evaluation Option for the constraints leaving the empty Sequence Container. The expressions vary but establish the mutual exclusivity of the expression. My Foreach Loop Container looks like this:

我希望这会有所帮助.

:{>

这篇关于SSIS:如果条件满足则执行第一个任务,否则跳到下一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆