tsells
tsells

Reputation: 2771

Receiving warning messages with EZAPI EzDerivedColumn and input columns

I am working with EZApi to assist in creating a package to stage data for transformation. It is working in terms of data movement. When opening the package in the designer however there are warning messages surrounding the Derived Column and the InputColumns being set to read only.

Warning 148 Validation warning. Staging TableName: {AA700319-FC05-4F06-A877-599E826EA833}: The "Additional Columns.Inputs[Derived Column Input].Columns[DataSourceID]" on "Additional Columns" has usage type READONLY, but is not referenced by an expression. Remove the column from the list of available input columns, or reference it in an expression. StageFull.dtsx 0 0

I can manually change them in the designer to be Read/Write or unselect them and the warning goes away. I am unable to get this to work programmatically however.

I have tried removing the columns from the metadata which works but doesn't remove them from the component so the columns are still created in the xml.

XML section

<externalMetadataColumn refId="Package\Full\Staging TableName\DestinationStaging TableName.Inputs[OLE DB Destination Input].ExternalColumns[DataSourceID]" dataType="i4" name="DataSourceID" />

When I try to go to the underlying object and delete the column using component.DeleteInput(id) I get an error message stating that the input column cannot be removed.

0xC0208010
-1071611888
DTS_E_CANTDELETEINPUT
An input cannot be deleted from the inputs collection.

Here is the code I am using to create a data flow task with an OLEDB Source, Derived Column, and OLE DB Destination.

Note that the input columns are not present until after the derived column is attached to the Source: dc.AttachTo(source);

 public class EzMyDataFlow : EzDataFlow
    {
        public EzMyDataFlow(EzContainer parent, EzSqlOleDbCM sourceconnection,
          EzSqlOleDbCM destinationconnection, string destinationtable, string sourcecomannd, string dataflowname)
            : base(parent)
        {
            Name = dataflowname;

            EzOleDbSource source = new EzOleDbSource(this);
            source.Connection = sourceconnection;
            source.SqlCommand = sourcecomannd;
            source.AccessMode = AccessMode.AM_SQLCOMMAND;
            source.Name = string.Format("Source_{0}", dataflowname);

            EzDerivedColumn dc = new EzDerivedColumn(this);

            dc.Name = "Additional Columns";

            // Setup DataSourceID
            string columnName = DBSchema.ReportFoundationalColumns.DataSourceID;
            dc.InsertOutputColumn(columnName);
            dc.SetOutputColumnDataTypeProperties(columnName, DataType.DT_I4, 0, 0, 0, 0);
            var c = dc.OutputCol(columnName);
            var property = c.CustomPropertyCollection["Expression"];
            property.Name = "Expression";
            property.Value = "@[TM::SourceDatabaseID]";
            property = c.CustomPropertyCollection["FriendlyExpression"];
            property.Name = "FriendlyExpression";
            property.Value = "@[TM::SourceDatabaseID]";

            dc.AttachTo(source);

            EzOleDbDestination destination = new EzOleDbDestination(this);
            destination.Table = destinationtable;
            destination.Connection = destinationconnection;
            destination.Name = string.Format("Destination{0}", dataflowname);
            destination.AttachTo(dc);
        }
    }

Upvotes: 1

Views: 461

Answers (0)

Related Questions