Showing posts with label dataflow. Show all posts
Showing posts with label dataflow. Show all posts

Tuesday, March 20, 2012

Script Question inside a DataFlow

Is it possible to iterate over all of the fields of the Row collection inside of the Script Component of a data flow. Basically, want I want to is to check every incoming column (all are strings) for a particular character sequence, and if found, change it to something else. I am current accessing each field as Row.Field1, Row.Field2, etc. and just thought there must be a better way to do something like:

For each col in Row

if row.col = XXX then do something.

End For

Thanks in advance for your help

gsell wrote:

Is it possible to iterate over all of the fields of the Row collection inside of the Script Component of a data flow. Basically, want I want to is to check every incoming column (all are strings) for a particular character sequence, and if found, change it to something else. I am current accessing each field as Row.Field1, Row.Field2, etc. and just thought there must be a better way to do something like:

For each col in Row

if row.col = XXX then do something.

End For

Thanks in advance for your help

Well, you COULD do that but, trust me, it would be much much slower than what you are already doing. To loop over the data this would need to be an asynchronous (sometimes called a blocking) component and these are slow.

The correct way to do this is what you are already doing.

-Jamie

Wednesday, March 7, 2012

script component Name Ouput0Buffer is not Declared?

Doing a simple test with a script component in a DataFlow to transform some data from a flat file. I have new columns under the default Ouput 0 .. however in my code when I try this, I get the above error.

Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)

Output0Buffer.AddRow()

End Sub

There will of course be a lot more code in the Script Component, but not clear on why I can't reference it.

Do you need to add a new row? Or are you just assigning a value to a new column on the existing row? The Row object should expose all of the columns you added.|||

JCNET wrote:

Doing a simple test with a script component in a DataFlow to transform some data from a flat file. I have new columns under the default Ouput 0 .. however in my code when I try this, I get the above error.

Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)

Output0Buffer.AddRow()

End Sub

There will of course be a lot more code in the Script Component, but not clear on why I can't reference it.

Is this a synchronous or an asynchronous component? If it is synchronous then calling the AddRow() method is not valid. You cannot add rows to the output of a synchronous component.

-Jamie

Script Component - Code not saving after edit

I have SQL Server 2005 Developer Edition. I have a script component in one dataflow which I have added code to today. I saved using the save Icon and exited. I noticed a warning on the item, so I went back into the script and my changes had gone. I though I could not of saved the code and retyped, saving every 5 minutes. I closed visual studio, and noticed the script component had the warning on again! I went back to the code and all my changes were gone. I did not see any errors or warnings in Visual Studio. What am I missing, retyping code becomes tedious!Forgive me if this is obvious to you, but you have to click OK from the script transformation editor to save your code. Clicking the save button in the VSA Editor doesn't do anything useful.
|||

Thanks for the reply.

I did click OK each time. I deleted the Script object and started again, no problems with the new component. Just one of those Microsoft mysteries I think!