简体   繁体   中英

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. 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. 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.

Add a column IsInsert and IsUpdate and the use the above expressions. 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. Call it something like DER Compute Changed Flags to indicate we're computing the whether the column has changed.

In this Derived Column component, you'll break out each column change check ie

  • Changed_ORDER_TYPE [Copy of ORDER_TYPE] != ORDER_TYPE
  • Changed_WEEK [Copy of WEEK] != WEEK

That then simplifies the IsUpdate logic to 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.

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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