Welcome to EMC Consulting Blogs Sign in | Join | Help

SSIS Junkie

SSIS: Check IsSorted property of the Virtual Input rather than the Input

A short FYI here to anyone building custom SSIS components. If you need to find out whether the component's input is sorted or not you cannot check the IsSorted property of the input - it will always return false regardless of whether the input is sorted or not. Instead, you need to check the virtual input.

In other words, the following code inside the Validate() method will always return DTSValidationStatus.VS_ISBROKEN:

        public override DTSValidationStatus Validate()

        {

            IDTSComponentMetaData90 metadata = this.ComponentMetaData;

            if (!metadata.InputCollection[0].IsSorted)

            {

                PostError("Input must be sorted");

                return DTSValidationStatus.VS_ISBROKEN;

            }

            else

            {

                return DTSValidationStatus.VS_ISVALID;

            }

        }

Whereas the following simple amendment will return DTSValidationStatus.VS_ISBROKEN or DTSValidationStatus.VS_ISVALID as appropriate:

        public override DTSValidationStatus Validate()

        {

            IDTSComponentMetaData90 metadata = this.ComponentMetaData;

            IDTSVirtualInput90 vinput = metadata.InputCollection[0].GetVirtualInput();

            if (!vinput.IsSorted)

            {

                PostError("Input must be sorted");

                return DTSValidationStatus.VS_ISBROKEN;

            }

            else

            {

                return DTSValidationStatus.VS_ISVALID;

            }

        }

The rationale for this is explained here by the architect of the dataflow, Matt David. To paraphrase Matt, the IsSorted property of the input is dependant on whether any columns are selected or not. This is not the case with the Virtual Input.

-Jamie

 

Published 08 January 2007 02:11 by jamie.thomson

Comments

 

Mike Groh said:

Once again, Jamie, thanks for your excellent code. Although the solution you show here is not directly related to an issue I have, it pointed the way to its resolution.

I wanted to retrieve the name of a Script Component so that, in the event of an error, I could include the offending Script Component's name in the log. Here's the little bit of code I used (this is, of course, a code fragment from within the Script Component):

Dim cm As IDTSComponentMetaData90

cm = Me.ComponentMetaData

Then, in the exception handler:

Me.ComponentMetaData.FireError(1, "Script Component", _

   cm.Name & ":" & ex.Message, "", 0, True)

I'm sure there are other ways to do this, but it's very cool to hook into the Script Component's properties through the IDTSComponentMetaData90 interface.

April 23, 2007 17:28
 

jamie.thomson said:

My pleasure Mike.

Agreed, Me.ComponentMetadata is incredibly useful.

-Jamie

April 23, 2007 17:48
New Comments to this post are disabled

This Blog

Syndication

Powered by Community Server (Personal Edition), by Telligent Systems