Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tool cannot see variable defined at data flow task level and used by source #27

Closed
tgauchet opened this issue Sep 7, 2018 · 7 comments
Assignees

Comments

@tgauchet
Copy link

tgauchet commented Sep 7, 2018

I have one SSIS 2012 package with a data flow task using as source a SQL query defined in string variable.
This variable is not defined at package level but at Data Flow Task level.
but the code is looking for variable at package level only.
Exception is triggered by GetVariable method.

@keif888 keif888 added the bug label Sep 10, 2018
@keif888 keif888 self-assigned this Sep 10, 2018
@tgauchet
Copy link
Author

As a workaround I have transmitted from the component to the data flow source the variables list. It is not very nice but it allows me to catch the issue and then use in catch section the array.
Of course I am interested If you have better!
SsisEnumerator.txt

@tgauchet
Copy link
Author

Just for information. Note that issue is also existing at other placer like with task to execute child packages. We are using "local" variables to pass parameters..
Thank you for your great work!

@keif888
Copy link
Owner

keif888 commented Sep 11, 2018

Latest code commit has fix for this issue. Corrected by passing the taskHost down to where the variables are being extracted, and checking both the SSIS package level, and the taskHost level for the variable.
This has been tested against variables in a Data Flow, and in the For Loop, that contains a Data Flow.

@tgauchet
Copy link
Author

Thanks a lot. My first test are working fine.
Just a remark, you are coding:
if (package.Variables.Contains(strVariableName))
return package.Variables[strVariableName].Value.ToString();
else if (taskHost.Variables.Contains(strVariableName))
return taskHost.Variables[strVariableName].Value.ToString();
else
but I believe that SSIS is doing the contrary in case you have 2 variable with same name. It will first check the local one and then the upper ones. (I will check tomorrow). So I would write:
if (taskHost.Variables.Contains(strVariableName))

            else if (package.Variables.Contains(strVariableName))
                
            else

Thanks a lot!

@fmms
Copy link
Contributor

fmms commented Sep 11, 2018 via email

keif888 added a commit that referenced this issue Sep 12, 2018
@keif888
Copy link
Owner

keif888 commented Sep 12, 2018

I have changed the order of execution to taskHost, then package, for the selection of a variable. I have since tested, and seen that you can have the same named variable at different Scope's.

@tgauchet
Copy link
Author

Thanks a lot!

@keif888 keif888 closed this as completed Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants