简体   繁体   English

SSIS 中的 INSERT/UPDATE 条件拆分工作不正确

[英]INSERT/UPDATE conditional split in SSIS working incorrectly

I looked for an answer for my specific issue before posting.在发布之前,我为我的特定问题寻找了答案。 Didn't find anything.没有找到任何东西。 I have a conditional split in SSIS that is inserting and updating, except that it seems to be updating 250+ rows each time it runs, whether an update was made to the source or not.我在插入和更新的 SSIS 中有一个条件拆分,除了它每次运行时似乎更新 250 多行,无论是否对源进行了更新。 Insert works correctly.插入工作正常。 But it only works when I "ignore error" on the conditional split, otherwise the split " evaluated to NULL, but the "Conditional Split" requires a Boolean results " error shows up.但它仅在我对条件拆分“忽略错误”时才有效,否则拆分“评估为 NULL,但“条件拆分”需要布尔结果“错误出现。 Any idea on how I can fix this?关于如何解决这个问题的任何想法? My conditional split looks like this:我的条件拆分如下所示:

UPDATE = [Copy of ORDER_TYPE] != ORDER_TYPE || [Copy of WEEK] != WEEK || [Copy of GOAL] != GOAL || [Copy of WEEK_START] != WEEK_START || [Copy of WEEK_END] != WEEK_END || [Copy of DIVISION_DESC] != DIVISION_DESC || [Copy of SUB_ORDER_TYPE] != SUB_ORDER_TYPE
INSERT = ISNULL(ID) || ISNULL(WEEK) || ORDER_TYPE == ""

I followed this tutorial.我跟着这个教程。

In a situation like this, it's impossible for us to debug what is happening as we don't have access to your data, your package and the results of the above boolean conditions.在这种情况下,我们无法调试正在发生的事情,因为我们无法访问您的数据、您的包和上述布尔条件的结果。 What I do, when faced with a problem like this, is to add one, possibly two, Derived Column task before the Conditional Split.当遇到这样的问题时,我所做的是在条件拆分之前添加一个,可能是两个派生列任务。 The first I'd called DER Action Flags as we'll generate the boolean conditions for the action we should take.第一个我将其称为DER Action Flags因为我们将为我们应该采取的操作生成布尔条件。

Add a column IsInsert and IsUpdate and the use the above expressions.添加列IsInsertIsUpdate并使用上述表达式。 Now connect your derived column to the Conditional Split and replace the two expressions to just use our new derived columns.现在将您的派生列连接到条件拆分并替换两个表达式以仅使用我们新的派生列。 Add a data viewer immediately before the split and you can verify whether your logic is sound.在拆分之前立即添加数据查看器,您可以验证您的逻辑是否合理。

Given the length of your UPDATE expression, I would break that into individual column evaluations in a derived column before DER Action Flags I described above.鉴于您的 UPDATE 表达式的长度,我会在我上面描述的DER Action Flags之前将其分解为派生列中的各个列评估。 Call it something like DER Compute Changed Flags to indicate we're computing the whether the column has changed.将其称为DER Compute Changed Flags之类的东西,以表明我们正在计算列是否已更改。

In this Derived Column component, you'll break out each column change check ie在此派生列组件中,您将分解每个列更改检查,即

  • Changed_ORDER_TYPE [Copy of ORDER_TYPE] != ORDER_TYPE已更改_ORDER_TYPE [Copy of ORDER_TYPE] != ORDER_TYPE
  • Changed_WEEK [Copy of WEEK] != WEEK Changed_WEEK [Copy of WEEK] != WEEK

That then simplifies the IsUpdate logic to Changed_ORDER_TYPE || Changed_WEEK...然后将IsUpdate逻辑简化为Changed_ORDER_TYPE || Changed_WEEK... Changed_ORDER_TYPE || Changed_WEEK...

Now that data viewer will show you the exact condition that is resulting in the Change to be erroneously flagged.现在,数据查看器将向您显示导致错误标记更改的确切条件。 That distills the problem down to these two inputs and this expression are not evaluating as expected (and that is something we can figure out)这将问题归结为这两个输入,并且此表达式未按预期进行评估(这是我们可以弄清楚的)

Based on your "ignore error" comment, I assume you have a condition with NULL comparison that might not be covered by the referenced link.根据您的“忽略错误”评论,我假设您有一个带有 NULL 比较的条件,该条件可能未包含在引用的链接中。

And since this is a series of Comments converted to an answer,由于这是一系列转换为答案的评论,

That worked.那奏效了。 The data viewer showed that one of my input columns was converting as float, while the table datatype was int, so the values with decimals are different than those in the table, as they get converted as int.数据查看器显示我的输入列之一正在转换为浮点数,而表数据类型为 int,因此带小数的值与表中的值不同,因为它们被转换为 int。 fixed.固定的。

Future readers, verify your data types (double click the connector lines out of a component and select MetaData) a consistent as data conversion rules might surprise you in unexpected ways.未来的读者,请验证您的数据类型(双击组件外的连接线并选择 MetaData)是否一致,因为数据转换规则可能会以意想不到的方式让您感到惊讶。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM