question

mk2012 avatar image
mk2012 asked

SSIS executing 2 packages within a package.

Hi I am runnig a SSIS package in 2005 which decides which of the two packages to run. There is a C# script that check which file is in a folder and if it's file A, package A runs and package B if it's file B. if the child packages are running separately(outside the main calling package) they run fine. If they are run from the main package. Package A seems to rerun once package B has finished. I have tried delay validation but not sure what is going on as individually they work fine in that they pick up the correct file for each child package, but the moment they run concurrently, it's as if SSIS can't deal with this. Anybody seen this before? Jay
ssis
3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Pavel Pawlowski avatar image Pavel Pawlowski commented ·
Can you post a screenshot of your master package how the child packages [A] and [B] are connected using precedence constraints to the Script task which is deciding which one you be run? Alsso, can you provide and ifnormation about expressions used on the precedence constraints? In general there shoul d be no problem to run your scenario.
1 Like 1 ·
mk2012 avatar image mk2012 commented ·
Thanks guys Please find attached calling package and one child package. The two calling packages are copies of eachother but I have changed one of them to pick up slightly different file type. Expression in the header package: @StatExists==true @InFileExists==true
0 Likes 0 ·
mk2012 avatar image mk2012 commented ·
ALSO: The C# script is calculating / updating boolean variables depending on the presenece of one or both files and then this follows through to the child packages. If both Bool's are true then both run. This bit works fine. I don't think it's the script or the loop. If I disable everything in the main package and have just two execute package tasks on a new SSIS package, then still there is an issue it's as if there is variable that is shared between the two packages that causes one to run twice. As I say, the two child packages are copies of each other with one slightly modified. If I run one from the calling package then end execution, then run the other and end execution it's fine. But in parallel or one after the other, SSIS gets confused. eg.@StatExists==true
0 Likes 0 ·
mk2012 avatar image
mk2012 answered
Sorted it. The two child packages were reading eachothers variables, even though they were not passed from the calling package and I had disabled all configurations, and limited the scope of the variables. Behind the scenes SSIS was storing these variables globally across all the packagesIn the end I added two extra VB scripts to check the variable values in the child packages and they were swapping valued.So to resolve I created one new replacement child package and a new calling package. I renamed all variables and method calls and objects. Then it worked.Thanks for your help
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

tomgough79 avatar image
tomgough79 answered
I'm not sure I quite understand your scenario (ie why it would run both), but one method I've seen to achieve a similar thing might help. This avoids the C# script altogether and in fact uses the foreach loop container. In short, you use the foreach loop container to pick up the file name into a variable which you then use as an expression in the precedence constraint coming from the foreach loop and on 2 different paths into each of the run package tasks. Caveat: if both types are in the folder, this will only run one of them. If this is the case, this method WILL NOT WORK.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Pavel Pawlowski avatar image
Pavel Pawlowski answered
You should setup the package execution like on the image below: ![SSISPackage Execution][1] In case both file exists, both will be executed. If only one of them, than only one file exists, only the package for the particular file will be executed. [1]: /storage/temp/648-ssisexecution.png

ssisexecution.png (11.4 KiB)
4 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

mk2012 avatar image mk2012 commented ·
Hi Pavel. That's exactly the structure I have.
0 Likes 0 ·
Pavel Pawlowski avatar image Pavel Pawlowski commented ·
So in that case, if you properly set the variables inside the script, than the packages will be also executed as requested. To check whether you have set the variables properly, you can set breakpoint on the **`OnPostExecute`** event of the Script Task. Then you can inspect the actual state of the variables.
0 Likes 0 ·
mk2012 avatar image mk2012 commented ·
Hi Pavel the calling package is ok in terms of the variables that are being assigned. I have found the problem to be that within one of the child packages it is reading the variable value for the same variable in child package 2, despite it being renamed... Scope of the variable is set to the child package one but it reads the variable in child package 2...?
0 Likes 0 ·
Pavel Pawlowski avatar image Pavel Pawlowski commented ·
How you are reding the variables in child packages? using the Package Configurations? if so, than check the package Configuration ans your problem will lay there. Also remember, that in case you have renamed the variable in the master package, but not update the package configuraion of child package, than the variable will keep the value set during the design time as the configuration wil not be applied on that particular child package variable.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.