' set outer global variables
oPkg.GlobalVariables("CVar").Value = DTSGlobalVariables("PVar").Value
On Error Resume Next
' Execute the Package
if Err.Number <> 0 then
rval = 1
' Pass a child value or variable back to the parent
if oPkg.GlobalVariables("Completion_Status").Value = true then
rval = 0
rval = 2
DTSGlobalVariables("Execute_Status").Value = rval
' Clean Up
Set oPkg = Nothing
if rval = 0 then
Main = DTSTaskExecResult_Success
Main = DTSTaskExecResult_Failure
To explain a little further, I want to set a parent pkg DTSGlobalVariable "Execute_Status" based on the execution of the child package where:
- rval = 1 where fatal error caught by error handling.
- rval = 0 or 2 which are based on the return value from the child pkg.
Now, everything is fine until after some testing I have found that the process can't set DTSGlobalVariables("Execute_Status").Value in the case where a fatal error occurs on oPkg.Execute. The wierd thing is the local variable rval gets correctly set so the error handling works fine, but when I try to set DTSGlobalVariables("Execute_Status").Value = rval nothing happens. When I put a check before and after the line DTSGlobalVariables("Execute_Status").Value = rval, DTSGlobalVariables("Execute_Status").Value is empty.
Weirder still is that I have tried setting DTSGlobalVariables("Execute_Status").Value = 2 in a step before this step and when I check the value of this variable in steps immediately before and after this step the value is still 2, even afterwards. It's as though this code can't access DTSGlobalVariables after a fatal error has occurred, even if it is handled.
The problem I need to use this flag in later steps to interpret mutliple ways of 'failure'.