SSIS Custom transformation receive variable

我的未来我决定 提交于 2019-12-02 16:46:41

问题


I am creating a custom transformation in C# to be used in SSIS. I have already been able creating and adding the custom component and receive and alter data from a db source but I need more data to register in a log table. This data can only be passed with variables but I can't find a good explanation of how to add a readonlyvariable to my component.

I have tried to use IDTSVariable100 and VariableDispenser but I can't make sense of how to.

 public override void ProvideComponentProperties()
                    {
                        base.ProvideComponentProperties();
                        base.RemoveAllInputsOutputsAndCustomProperties();
                        VariableDispenser varDispenser = this.VariableDispenser();

                        IDTSVariable100 vr = this.VariableDispenser.GetVariables();
                        IDTSInput100 input = this.ComponentMetaData.InputCollection.New();
                        input.Name = "Input_B";

                        IDTSOutput100 output=this.ComponentMetaData.OutputCollection.New();
                        output.Name = "Output_B";

                        // the output is synchronous with the input
                        output.SynchronousInputID = input.ID;

                     }

Basically i want to define readonlyvariables that I can alter the value before my custom component runs like the original "script component" has.


回答1:


Well i researched a bit more and stumbled on a answer: It seems that to access the SSIS public variables we have to get them with code on the ProcessInput Method:

var dimSrcId ="";

IDTSVariables100 variables = null;

this.VariableDispenser.LockForRead("User::dimSrcId");

this.VariableDispenser.GetVariables(out variables);

dimSrcId = variables["User::dimSrcId"].Value.ToString();

variables.Unlock();

By using the VariableDispenser.LockForRead() we're capable of searching for our variables and access there value.



来源:https://stackoverflow.com/questions/32224337/ssis-custom-transformation-receive-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!