Page 1 of 2

Store User Names, Passwords, DataSource Names

Posted: Fri Feb 09, 2007 10:45 am
by just4geeks
In my job, I use a database stage and I usually fill in the DataSource Name, User Name and Password directly in the fields.

But is there a way to store these variables in a file that the job can read from during runtime? This will let me change the values of the variables in the file and not in the job in the event that the data source name or username changes. Moreover, does DS let me encrypt/decrypt the file?

Thanks for your help in advance....

Posted: Fri Feb 09, 2007 10:49 am
by DSguru2B
You can define them as environment variables in the Administrator and use $PROJDEF in their place inside your stages. This way all you need to do is change the values in the administrator and the jobs will pick up the correct value during runtime.

Posted: Fri Feb 09, 2007 10:57 am
by just4geeks
DSguru2B wrote:You can define them as environment variables in the Administrator and use $PROJDEF in their place inside your stages. This way all you need to do is change the values in the administrator and the jobs will pick up the correct value during runtime.
Thanks for your answer.

However, if I type $PROJDEF for all of database source name, user id, and password, how does it know to associate which field to which environment variable?

I have set my environment variables as follows.
Image

And in the database stage,
Image

Posted: Fri Feb 09, 2007 10:59 am
by ArndW
No, you use the $PROJDEF as the parameter value and continue to use the parameters to fill out the different columns in your job.

Posted: Fri Feb 09, 2007 11:10 am
by chulett
Or... if you really wanted to go that route... store them in a file. 'Encrypt' the file if you like. You would then need to have some home-brewed Job Control in place to read (and possible decrypt) that information and dynamically set those values when starting the jobs.

Many of us have such a beastie in place from long before the $PROJDEF option became available. However, for people not in that boat, I'd suggest taking the new route - assuming you are on a 'recent' 7.x release of DataStage like 7.5 and up. From what I recall, it didn't quite work right at first. :?

Posted: Fri Feb 09, 2007 11:15 am
by just4geeks
chulett wrote:Or... if you really wanted to go that route... store them in a file. 'Encrypt' the file if you like. You would then need to have some home-brewed Job Control in place to read (and possible decrypt) that information and dynamically set those values when starting the jobs.

Many of us have such a beastie in place from long before the $PROJDEF option became available. However, for people not in that boat, I'd suggest taking the new route - assuming you are on a 'recent' 7.x release of DataStage like 7.5 and up. From what I recall, it didn't quite work right at first. :?
By new route, you mean the $PROJDEF route, right?...If so, I think I am sticking to the new route. I am using 7.5.2.

Thanks chulett

Posted: Fri Feb 09, 2007 11:18 am
by narasimha
just4geeks wrote:By new route, you mean the $PROJDEF route, right?
Right!

Posted: Fri Feb 09, 2007 11:42 am
by tonystark622
Or... if you really wanted to go that route... store them in a file. 'Encrypt' the file if you like. You would then need to have some home-brewed Job Control in place to read (and possible decrypt) that information and dynamically set those values when starting the jobs.
Actually, you can do this in a Routine... I use a UserVariables Activity, define a variable and in the Derivation call my GetParameterFromFile routine to retrieve the value. You can then pass it into a job by using the Elipsis button and selecting the UserVariables stage (I call mine PARAMETERS) and the Variable name. This might look like:

Code: Select all

GetParameterFromFile(JobParameterFileName, "DB_NAME")
The data is stored in the file as name, "=", and value, like this:
DB_NAME=yourDB
DB_USER=yourUser
DB_PWD=yourPWD

If you gin up your own encryption/decryption routines, you can use a different routine to decrypt the password when it's fetched from the file.

Good luck,
Tony

Posted: Fri Feb 09, 2007 11:52 am
by Dsnew
Tony,

Can you please share your Routine. It will be very helpfull....

Thanks
Clara

Posted: Fri Feb 09, 2007 11:56 am
by just4geeks
tonystark622 wrote:
Or... if you really wanted to go that route... store them in a file. 'Encrypt' the file if you like. You would then need to have some home-brewed Job Control in place to read (and possible decrypt) that information and dynamically set those values when starting the jobs.
Actually, you can do this in a Routine... I use a UserVariables Activity, define a variable and in the Derivation call my GetParameterFromFile routine to retrieve the value. You can then pass it into a job by using the Elipsis button and selecting the UserVariables stage (I call mine PARAMETERS) and the Variable name. This might look like:

Code: Select all

GetParameterFromFile(JobParameterFileName, "DB_NAME")
The data is stored in the file as name, "=", and value, like this:
DB_NAME=yourDB
DB_USER=yourUser
DB_PWD=yourPWD

If you gin up your own encryption/decryption routines, you can use a different routine to decrypt the password when it's fetched from the file.

Good luck,
Tony

Thanks Tony for your answer....

However, I am lost. How do I get to the "UserVariables Activity" or the "UserVariables stage"?

I am just starting out....so I am not too familiar with DS.

Thanks for your time...

Posted: Fri Feb 09, 2007 12:04 pm
by chulett
The User Variables and Job Activity stages are available in Sequence jobs... are you using them to control your processing?

Posted: Fri Feb 09, 2007 12:05 pm
by just4geeks
chulett wrote:The User Variables and Job Activity stages are available in Sequence jobs... are you using them to control your processing?
I am not using Sequence Jobs at all. Is there no way to do what tony described in Server jobs?

Posted: Fri Feb 09, 2007 12:13 pm
by chulett
No. What Tony described is one of the many things Sequence jobs bring to the table - automation of parameter assigned being one such.

What are you using for 'job control'? You'll need to find a methodology that is compatible with that.

Posted: Fri Feb 09, 2007 12:17 pm
by just4geeks
chulett wrote:No. What Tony described is one of the many things Sequence jobs bring to the table - automation of parameter assigned being one such.

What are you using for 'job control'? You'll need to find a methodology that is compatible with that.
If I get what you mean my job control...then I run the jobs using a UNIX script.

Posted: Fri Feb 09, 2007 12:20 pm
by just4geeks
Tony,

It would be great if you could share your GetParameterFromFile routine..

Thanks,