Saturday, February 25, 2012

Records not updating in Script Component

I am seeing a strange behavior in a script component that I can't figure out.

Basically, there is a field in my script that checks to see if a string field is length of 1. If it is, it updates the field with some value. The strange behavior is that it picks up some of the rows but not others.

If Row.FieldValue.Length = 1 Then

Row.FieldValue= "Some Value"

End If

I've tried variations such as:
If left(Row.FieldValue.,1) = "-" Then


Row.FieldValue= "Some Value"


End If

But I get the same results. Any Ideas?Does [Field] need to be trimmed? Might some data contain trailing white spaces?|||

No, I've tried every combination of Trim, left, equals etc...that I can think of. The funny thing is that it picks up some of the fields and misses others.

Very puzzling. I was hoping to hear of some rare condition on this board that sounds similar to this, but I have yet to hear of any similar situations.

The code that I am talking about is incredibly simple, as shown in my previous post.

|||What happens when [Field] is null?|||

You could fire some debug iformation to help you. Something like this maybe:

Me.ComponentMetadata.FireInformation(,,Row.FieldValue.ToString() + " - " + Row.FieldValue.Length.ToString(), ....

-Jamie

|||

Thanks, that did it. I am relatively new to SSIS, never really delved into the debug information before.

that is very helpful.

|||

KML67 wrote:

Thanks, that did it. I am relatively new to SSIS, never really delved into the debug information before.

that is very helpful.

Great! But what solved your issue?|||

Basically, matching the string by length, equal, explicit match was working fine all along.

There was some logic that followed this string test that was providing the error. The error was very subtle, so it did not always produce the same value for the same input (depending on multiple variables), but at quick glance (watching the data flow into and out of the component with dataviewers) it looked as like there was an inconsistency in the component itself.

Jamie's post was very helpful, I am new to SSIS and wasn't familiar with the fireInformation method. That allowed me to solve it in a second.

Thanks for the tips, this board is a great asset.

No comments:

Post a Comment