I am developing a custom destination component and I have encountered a few areas where there seems to be a lack of helpful documentation and examples.
1. I have not been able to find any information on or examples of creating custom destinations with an error output. The OLE DB Destination has an error output so I investigated the input and error output properties in the advanced editor and found that the OLE DB Destination error output is synchronous with the input (its SynchronousInputID matches the input's ID) and has its ExclusionGroup value set to 1. Using this information, I modeled my error output after the OLE DB Destination.
ProvideComponentProperties:
AddErrorOutput(ERROR_OUTPUT_NAME, input.ID, 1);
ProcessInput:
int errorOutputID = -1;
int errorOutputIndex = -1;
GetErrorOutputInfo(ref errorOutputID, ref errorOutputIndex);
...
buffer.DirectErrorRow(errorOutputID, 0, errorOutputIndex);
Checking the input and error output properties in the advanced editor for my custom destination component I find the following:
Input
--
ID: 3515
Error Output
ExclusionGroup: 1
ID: 3516
IsErrorOut: True
SynchronousInputID: 3515
Shortly after I start my SSIS package and it encounters an error row, I get the following exception:
[My Destination Adapter 1 [3512]] Error: System.ArgumentException: Value does not fall within the expected range. at Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSBuffer90.DirectErrorRow(Int32 hRow, Int32 lOutputID, Int32 lErrorCode, Int32 lErrorColumn) at Microsoft.SqlServer.Dts.Pipeline.PipelineBuffer.DirectErrorRow(Int32 outputID, Int32 errorCode, Int32 errorColumn) at MyDestination.ProcessInput(Int32 inputID, PipelineBuffer buffer) at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostProcessInput(IDTSManagedComponentWrapper90 wrapper, Int32 inputID, IDTSBuffer90 pDTSBuffer, IntPtr bufferWirePacket)
2. My custom destination component is used for writing a file with a fixed schema. I followed the means by which source component examples add their output columns, but applied this to my external metadata columns. In my Validate() I check if the ExternalMetadataColumnCollection.Count == 0 and return DTSValidationStatus.VS_NEEDSNEWMETADATA; to force a call to ReinitializeMetaData(). In ReinitializeMetaData() I call a method that creates the input's external metadata columns that reflect my external data source.
This works fine except every time I add my custom destination component to a SSIS Package and go to edit the component I am greeted with a dialog box that states: "The component is not in a valid state. ... Do you want the component to fix these errors automatically?" Pressing the Yes button, I assume, makes the call to ReinitializeMetaData() and I have my external metadata columns. Where is the correct place to add the external metadata columns so the user does not have to take this extra step every time they add my component to their package?
This sample component illustrates error outputs: http://www.microsoft.com/downloads/details.aspx?FamilyID=7952c866-807b-4715-80ba-498e0a16ab18&DisplayLang=en
There are some other component examples at: http://www.microsoft.com/downloads/results.aspx?pocId=&freetext=ssis&DisplayLang=en
Donald
|||Thanks for directing me to the example, that helped me figure out why I am getting the exception, but it would be helpful if someone could address my questions.
Should the error output on a destination component be synchronous?
In the example Donald referred to I noticed they were not using a zero value for the error code, which was different from the examples in the Wrox Professional SSIS book, the MSDN documentation for the DirectErrorRow Method ( http://msdn2.microsoft.com/en-us/library/microsoft.sqlserver.dts.pipeline.pipelinebuffer.directerrorrow.aspx ), and “Using Error Outputs” in SQL Server 2005 Books Online (http://msdn2.microsoft.com/en-us/library/ms136009.aspx ) If the use of a zero value for the error code is the reason for the System.ArgumentException, why are the examples using a zero value? Is it documented anywhere that a zero value is an invalid argument to the DirectErrorRow Method?
Although it isn’t on the topic of error outputs, does anyone have any comments on question number 2 in my original post?
|||There is an event which fires when someone makes a connection to your component OnOutputPathAttached you can put your code in there.
|||Thank you for your reply.
However, I am not sure if this solves my issue 2.
Since I am writing a desitnation transformation, no regular output will be attached to the transformation, will the OnOutputPathAttached be called under this circumstance?
I could probably set up my ExternalMetdData at OnInputPathAttached, but it does not make a whole lot of sense to me since the ExternalMetdData does not depend in any way on the input.
I am thinking about putting it in ProvideComponentProperties, but if there is a better place for it based on the SSIS architecture, I would very much like to know about it.
Thanks.
No comments:
Post a Comment