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

Logging and 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.

Last modifications : 21.07.2011
Run into errors ralated to Variable Deadlocking. After houres of research, I found out how exectly that stuff works in boith the Control-
and the Dataflow Last modifications are related to Lock/Unlock problems. So in case of an error and a variable was locked before, but
not unlocked, you could run into DeadLock situations. I found a solution after some trouble and do the Unlock which have be done in
Read / Write functions in the finally section, so it guarantied, that each variabel which was locked, is afterwards unlocked.

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)