Submitted byCategory
Review Cycle
.
Public
Joachim Mutter/sysarc
on 05/30/2008 at 04:53 PM
SSiS\Code, SSiS\Doku

Variables

Variables in SSiS are a never ending story. Sometimes you think you have everything understood, but a few days later, you run into an error handling variables.

So after houres of research, I found out how exectly that stuff works in boith the Control- and the Dataflow

ControlFlow

Parent package configurations can be used to produce an almost opposite behaviour. They are used to receive values from a parent package IF the package has been called by a parent package. I like to use the analogy that this is like passing ByValue whereas the scenario explained above is a bit like passing ByRef.             If Dts.VariableDispenser.Contains(varName) Then    ' Should we check or should we throw an error in case of no exisitnace?
                If isSystem Then ' Use System way to access variables
                    Call Dts.VariableDispenser.LockOneForRead(varName, vars)        ' Locks only this variable and returns it in the vars collection
                    result = vars(varName)                                          ' Read variable
                    vars.Unlock()                                                   ' And unlock it
                Else ' Script Task collection
                    vars = Dts.Variables                                            ' Get the tasks variable collection, which is already locked,
' donot unlock it, if you want to iterate over it !!!
                    result = vars(varName)                                          ' Read variable
                End If For Each prop As PropertyInfo In me.Variables.GetType().GetProperties()
      mMain.VariableDispenser.LockForRead(prop.Name)
Next
      Call mMain.VariableDispenser.GetVariables(mVars)