Passing a global variable to an Execute Package Task

  • I'm trying get an Execute Package Task to get the value of a global variable that's set by a previous Execute SQL Task. Looking at the Execute Package Task properties, it looks like the task can only pass a static value. Am I right about that?

    I'm 99% sure that the SQL task is setting the GV correctly. When I manually change the GV's value in the Execute Package task, the called DTS package displays that value.

     

     

  • Dear Newbie,

    I spent a lot of time fighting with that problem.

    The only solution that I found was this:

    ****************************************************************************************************

    Dim oPackage, oTaskTransform

    SET oPackage = DTSGlobalVariables.parent

    SET oTaskTransform = oPackage.Tasks.Item("DTSTask_DTSExecuteSQLTask_1").CustomTask

    ' 00000 is a value in the Execute task that I want to replace (you can make it anything that does not make any sense in your package)

    oTaskTransform.SQLStatement = Replace(oTaskTransform.SQLStatement, "00000", GlobVar)

    *****************************************************************************************************

    I guess that Global Variables would not work in DTS Packages (SQL2K). Do not forget to reset this value to '00000' or whatever again

     

  • Make sure you're setting the outer global varible in the Execute Package task to calling package's global variable and that the global variable in the child package is spelled exactly the same.

    Greg

    Greg

  • I'm having a very similar problem. I'm new to global variables, but what I'm trying to do seems straight forward enough if I'm reading the documentation correctly.

    I have one package with a branch in it that runs one branch if an integer global variable is '0' and the other branch if the gv is '1'. This works fine.

    I have another package with an Execute Package Task (EPT) to call the first package. In the EPT properties I have:

    EPT Inner Package gv: Child_Partial - Integer - 1

    EPT Outer Package gv: Child_Partial

    Parent Package gv Properties: Child_Partial - Integer - 0

    I can change the Inner Package gv value back and forth and it sends properly to the child package and runs the correct branch. However, my understanding is that I should be able to change the GV value in the Properties for the Parent package and this should pass to the child. This is not happening.

    Any suggestions greatly appreciated.

    Brad

  • I resolved my issue with further testing. Perhaps it is a useful clarification.

    Originally I had this:

    EPT Inner Package gv: Child_Partial - Integer - 1

    EPT Outer Package gv: Child_Partial

    Parent Package gv Properties: Child_Partial - Integer - 0

    I only needed this:

    EPT Outer Package gv: Child_Partial

    Parent Package gv Properties: Child_Partial - Integer - 0

     

    I thought I needed entries on both tabs to show the mapping, but you only need it on the Outer, and if the variables are set up correctly, the mapping is automatic. Setting the Inner Package gv will override the outer value.

    Hope this helps someone.

    Brad

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply