chuck620


I have a parent package that calls a child package, when I run the parent package the child package picks up a variable value from the parent in a script task and runs fine, the problem I'm facing is when I run just the child package, the script task fails because it doesn't know about the parent variable. The dilemma I'm facing is in my child script task, if I add the parent variable to the ReadOnlyVariables list then the task fails because the parent variable doesn't exist when I just run the child. If I don't add the parent variable to the ReadOnlyVariabls list then if I try to use it then the task fails saying that the variable doesn't exist in the variables collection.

Is there a way to check for the existence of the parent variable, so when I just run the child package I don't get an error and I don't have to change my task every time I choose to run the child package only vs running the parent/child

Thanks.




Re: Checking for existence of parent variable in child package

Phil Brammer


You're mapping the parent variable to the child variable, correct

The package shouldn't fail -- it should just revert to the default value of the child variable.






Re: Checking for existence of parent variable in child package

Eric Wisdahl

I don't know that he used the parent package configurations... he probably used the system of just using the parent variable name in the script task without passing this by the parent package configurations... http://vsteamsystemcentral.com/cs21/blogs/steve_fibich/archive/2007/09/29/passing-a-value-back-and-forth-from-a-parent-package-to-a-child-package-in-ssis.aspx







Re: Checking for existence of parent variable in child package

chuck620

Basically this is what I have:

Parent Package

Variable: P_SCHEDULE_JOB_ID

Child Package

Variable: SCHEDULE_JOB_ID

Script Task:

ReadOnlyVariables: P_SCHEDULE_JOB_ID

ReadWriteVariables: SCHEDULE_JOB_ID

Dts.Variables("SCHEDULE_JOB_ID").Value = Dts.Variables("P_SCHEDULE_JOB_ID).Value.ToString()

Which works fine when I run the parent package and it calls the child package. When I run only the child package it has no knowledge of the parent package variable and causes the task to fail.





Re: Checking for existence of parent variable in child package

Phil Brammer

Use parent package configurations to pass the parent variable down to the child variable.

What you are attempting to do is provided with built-in functionality and a script is not needed.

Right click on the control flow background and select "Package Configurations." Enable package configurations. Then Add a new one, selecting "Parent package variable" as the configuration type. Simply type in the name of the parent variable (P_SCHEDULE_JOB_ID) and then click Next. Then, choose the "Value" property of the child variable. From there you can exit the wizard by following the prompts.

That sets up a parent->child relationship correctly.





Re: Checking for existence of parent variable in child package

chuck620

That worked, thank you for your help.