Understanding the Script Component


The Script component allows you to implement custom behaviors in Data Flow. As you have already learned in the last few chapters, SSIS provides three kinds of Data Flow components: Source, Transformation, and Destination. The Script component can be used as any of these types.

The Script component is often useful in the following cases:

  • You would like to process a custom-format flat file as a data source.

  • You would like to validate a value in a certain row while loading data to your database.

  • You would like to feed data to a custom destination such as Web Services.

To use the Script component with other components, you need to define inputs and outputs of the Script component. When you use it as the source component, you have to define outputs, so you can connect to a downstream component such as a transformation or destination component. If you would like to use the Script component as a destination component, you have to define inputs. Otherwise, you have to define both inputs and outputs.

Figure 6-2 shows a basic programming model of the Script component. The way you implement it is slightly different from how you implement the Script task.

image from book
Figure 6-2: The Script component programming model

The Script component has unique objects called InputBuffer and OutputBuffer. InputBuffer provides a method to read data from an upstream component, and OutputBuffer provides a method to feed data to a downstream component. You will write a custom code working with these buffer objects to process the data in the Script component. Each buffer object has a set of properties synchronized with the definition of the inputs and outputs.

The number of buffers in the Script component varies by the number of inputs and outputs. The name of each buffer will be synchronized with the names of the inputs and outputs. For example, if you define two inputs, CustomerInput and OrderInput, you will have two InputBuffer objects, named CustomerInputBuffer and OrderInputBuffer, in the Script component.

Like the Dts object in the Script task, SSIS offers you some objects with which to access SSIS built-in capabilities from the Script component. The Me.Variables object provides access to package variables. The Me.ComponentMetadata object provides several methods to raise events from the Script component, as with the methods defined under the Dts.Event object in the Script task. The Me.ComponentMetadata object also provides the Log method, which works like the Dts.Log method in the Script task.

The other rules are the same as with the Script task. As you have learned in the previous section, you can incorporate other objects that are defined in external .NET assemblies in your Script component.




Microsoft SQL Server 2005 Integration Services Step by Step
MicrosoftВ® SQL Server(TM) 2005 Integration Services Step by Step
ISBN: 0735624054
EAN: 2147483647
Year: 2007
Pages: 152

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net