Does variable value set by Row Count Transformation take effect during execution of DFT in SSIS? or Conditional Split can read a variable correctly?

拈花ヽ惹草 提交于 2019-12-12 16:42:20

问题


I have a SSIS package where1 record (hard coded) flow through.

I have variable in DFT scope.

I assign value to variable using Row Count Transaformation.

The value should be 1 i verify it by using script component.

 public override void PostExecute()
  {
    System.Windows.Forms.MessageBox.Show(ReadWriteVariables[0].Value.ToString());
    base.PostExecute();
    /*
      Add your code here for postprocessing or remove if not needed
      You can set read/write variables here, for example:
      Variables.MyIntVar = 100
    */
  }

I look for zero condition through condition in Conditional split transformation.

Strangely it satisfies equal to zero condition whrease I think it should have value 1. Even Messagebox through script component shows value 1.

what could be the reason? Are value in varible realize only towards end of DFT or Conditional Split has some problem reading correct value or something else which i am not able to think up?


回答1:


The value for variable being assigned inside a data flow task can't be used in the split transformation or later in the Data Flow task . The values generally get populated once DFT gets completed .

Variable values does not update during the execution of Data Flow task 

Even though you are able to see value 1 or set some other value to Variable from script transformation in post or pre execution events ,these values gets effected only after the execution of DFT

Hence the updated value can be used in precedence constraint or other tasks in control flow .

Read this article .




回答2:


Alternatively you can use RANK Function as one of the columns, latter use Conditional split with max function to get the number of rows selected (in directly row count). Next you can use Copy column and remove RANK column before inserting into final destination. Hope this helps!



来源:https://stackoverflow.com/questions/15384108/does-variable-value-set-by-row-count-transformation-take-effect-during-execution

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