Wednesday, March 7, 2012

Assign Aggregate count results to variable

I have an aggregate transform that outputs two columns, a group by (DT_STR) and a count(column name) (DT_UI8). The results are put into a Recordset Destination. When I attempt to map these columns to variables in a Foreach Loop Container (using a Foreach ADO Enumerator), I get the error:

Error: 0xC001F009 at ExtractNNRPersonUpdates: The type of the value being assigned to variable "User::NNRPersonCount" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object.

Error: 0xC001C012 at Foreach Household Loop Container: ForEach Variable Mapping number 2 to variable "User::NNRPersonCount" cannot be applied.

The variable mentioned in the error message is setup as a UInt64. I've tried all other integer data types and nothing works. I also tried changing the data type of the count coming out of the Aggregate transform but received a warning stating this isn't possible.

Any idea what I may be doing wrong?

I had a lot of trouble with this error, and ended up doing explicit casts in a script where I was doing my comparison, using the CType function.

eg:

Row.newid = rowIndex + CType(Me.Variables.MyCounter, ULong)

Dylan.

|||Out of desperation, I began trying all of the data types. When I set it to DBNull, it worked. I was then able to cast it to an integer in a Script Task. Doesn't seem right though because the values are never null.

No comments:

Post a Comment