Sunday, March 11, 2012

Access to the property values for my expressions

I may be looking too hard for this but I can't find a way around it.

I have an Expression and in that expression, I want to access a property on the same object (it would be great to get the properties of other objects as well).

Example: I have a flat file connection where I defined the name of the flat file in my ConnectionString. I also have a variable that I have it linked to my dtsConfig which points to the proper folder name at run time.

How can I create an expression similar to this:

@.[User::strFolder] + @.[Connectionstring]

where @.[User::strFolder] is my variable and points to the correct folder for the given server the package is running on and @.[Conenctionstring] is my made up name to access the VALUE of the Connectionstring that I have for this flat file.

So if I have the following:

in my connectionstring property: flatfile.txt

in my strFolder derived from dtsConfig at runtime: E:\etl_data\

I would like my final connectionstring to look as follow:

E:\etl_data\flatfile.txt

So far I know I can do it with two variables but it would be great if I could reuse the property values of the current object for my expressions or any other object.

Perhaps this value is available thru the script where I can access "any" property in my dtsx and store it into another variable and then use it. This option at least allows me to reuse code instead of hardcoding table name (connectionstring) into my variables.

Did I make this too difficult and there is a simple way to access an object's property inside the expression builder?

Thanks

Anatole

I guess what you want to be able to do is specify the filename at design time and reuse that at runtime. Unfortunately you can't have both worlds. Either its set at design time with directly or via an expression.

I think your only option is to use two variables.

|||

HOw about just accessing any of the properties? Can it be done? So far I know I can access the system/pkg and user defined values.

For my example, if reading from & writing to the same property is not valid/acceptable, how about writing to ConnectionString using a Variable + another property value such as the description?

Anatole

|||

Package properties are read only at runtime. The only way to change them is via expressions.

This is a principle of the SSIS architecture.

Whats wrong with 2 variables?

|||

Simon,

Are they read-only or Not accessible? If read-only, I'll be happy with that as long as I can read them somehow and use expression to change them but perhaps you meant to say that SSIS engine reads them and not available to anyone else.

I'm OK with 2 variables but since I already have some 40 plus pkgs that read from flat files where the location is different once deployed, it would be great to write a simple expression using concatenation and substring (if needed to parse the file name) instead of adding two variables to every pkgs. The design changed and instead of using dtsconfig to change the location when the manifest is deployed, I now need to have a parent pkg execute file system pkgs droped in a folder.

The SSIS already has the functionality to pull the system properties. It can create variables and has this additional expressions available for us to manipulate the values at run time. Why restrict it to system properties? If they didn't allow us to change the value of a property at run-time, I can understand. But since we have this feature, why not allow us to read it?

Maybe in the next release they will have this access.

Thanks

Anatole

No comments:

Post a Comment