Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

SSIS - Passing Object Variable - Multiple parents to single Child Package - Variable scope Conflict

$
0
0

Hi,<o:p></o:p>

I'm working on a small project and as part of the project, I need to create a framework for future enhancements.<o:p></o:p>

This is what I'm doing:

Objective:

1. Get all records from the SQL Server database

2. Split records in to few sets.

3. One set will be passed to a "Execute Package" task.

4. "Execute Package" task (Parent) will execute "Child Package".

5. Child Package will do processing based on the input from Parent and insert records in to a SQL database.

Child Package:<o:p></o:p>

1. Script task receives Recordset from the Parent Package. Below is the code in the script:

publicvoid Main()

{

   Variables vars = null;

   Dts.VariableDispenser.LockForWrite("User::ChildRsServerNames1");

   Dts.VariableDispenser.LockForRead("User::ParentRsServerNames1");

   Dts.VariableDispenser.LockForRead("User::ParentRsServerNames2");

   Dts.VariableDispenser.GetVariables(ref vars);

   

   vars["User::ChildRsServerNames1"].Value = vars["User::ParentRsServerNames1"].Value;

   vars["User::ChildRsServerNames1"].Value = vars["User::ParentRsServerNames2"].Value;

   vars.Unlock();

   Dts.TaskResult = (int)ScriptResults.Success;

}

2. A recordset will be assigned to "Foreach Loop" container - ADO Enumerator Object Variable.

3. "Data flow" in the "Foreach Loop" container will insert records into the database.<o:p></o:p>

Parent Package:<o:p></o:p>

1. Get all records from the Database.<o:p></o:p>

2. Split records based on the master configuration.(For ex, if I have 20 records and user wants to split them into 4 sets then I will get 4
recordsets with 5 records each)<o:p></o:p>

3. Each recordset will be passed to the Child package using an object variable, for parallel processing. (It is proved for us that parallel processing is taking
less time than serializing)<o:p></o:p>

4. I created 4 "Execute Package" tasks and I pass a recordset to each "Execute Package" task.<o:p></o:p>

5. Each "Execute Package" task takes a recordset and pass it to the Child package.<o:p></o:p>

Issue:<o:p></o:p>

1. Parent Package is running exactly the same way that it was designed. Each "Execute Package" task is sucessfully passing recordset to the child package.(Multiple Parent Packages, different Recordsets,Single Child Package)<o:p></o:p>

2. When I'm passing Recordsets from the Parent to the Child Package. Child package is receiving recordsets firmly and doing its operations exactly the same it is supposed to.(This is True if I'm executing only one Parent Package instead of 4 at a time).<o:p></o:p>

3. Issue is four Parent Packages executing the same child package and child Package is considering only the last Parent Package recordset values and giving the same output for each Parent-Child execution like below diagram.

Question:

What changes do I need to make, so that child package will consider respective calling Parent Package values only and give respective outputs?

Please let me know if you need more information.


If you feel that I have answered your question then please Vote.


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>