dbTalk Databases Forums  

Passing values from child to parent package

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Passing values from child to parent package in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
sesh
 
Posts: n/a

Default Passing values from child to parent package - 05-21-2004 , 02:26 PM






Hi everyone

I am executing a child package from the parent package in DTS. I am passing a global variable, say x (via the outer global variables tab in execute property task) to the child package. I want to change the value of the variable x of the parent package from the child package.

I tried using this script in my child package to change the global variable value in the parent.

set obj=dtsglobalvariables.paren
obj.parent.globalvariables("x").value="baseball

I need the value to be changed in my parent package.

Thank



Reply With Quote
  #2  
Old   
Rand Boyd [MSFT]
 
Posts: n/a

Default RE: Passing values from child to parent package - 05-24-2004 , 03:36 PM






Here is an example that has worked in the past. Try and see if it works for
you:

In the parent package, you create an ActiveX script that is called before
the
Execute Package Task.
In the ActiveX Script, you include the following code to set one of the
Parents
Global Variables to the Parents Global Variable package.

Function Main()
Dim oPKG
Set oPKG = DTSGlobalVariables.Parent
Set DTSGlobalVariables("ParentVar").Value = oPKG
DTSGlobalVariables("TESTSTRING").Value = "Hello SQL SP"
Main = DTSTaskExecResult_Success
End Function

Then in the Execute Package Task, you pass the Variable to the child that
holds the
Parents Globabl Variable Package reference.

Then in the child package, you can use the following code to modify the
parent's
global variables in an ActiveX script.
This code assumes the parent has a globabl variable called TESTSTRING that
was not
passed to the child package.

Function Main()
Dim oParentPKG
Set oParentPKG = DTSGlobalVariables("ParentVar").Value
MSGBox(oParentPKG.GlobalVariables("TESTSTRING").Va lue)
oParentPKG.GlobalVariables("TESTSTRING").Value = "BYE SQL SP " ' set for
full
processing
Main = DTSTaskExecResult_Success
End Function

Rand
This posting is provided "as is" with no warranties and confers no rights.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.