Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Environment variables

Status
Not open for further replies.

brindavoine

Programmer
Jul 3, 2005
6
FR
I don't understand the environment variables in DataStage...

I am developping DS jobs for a multi-site company. The same job will have to run on each site. So I need a variable or a parameter, that I shall set once for each site, to have all my jobs using the same site code.

To my mind, this is what "environment variables" are made for. But it seems it doesn't like that :

When I define an environment variable in DS Administrator, I can set its value. If I use it in a job, it will be defaulted as in Administrator. But if I modify the value of the variable, the default is not modified in my job.
If I erase the default in the job, it does also not take the value set in Administrator.

Could somebody explain, or give another idea to solve my problem ?

Any help welcome...
 
An idea would be to have my variables in a sequential or hashed file. Every other job would refer to this file to get the value of the variables.

But how could it work if I need my variables to define a path or a file name (e.g. #path#FileName#SiteCode#.txt, in the input or output tab for a sequential file stage, where #path# and #SiteCode# are 2 variables or parameters) ?
 
There is now a FAQ on project specific environment variables over on the DataStage Exchange at With the latest updates to version 7.x of DataStage it is possible to do all dynamic variable handling via project specific environment variables read by sequence jobs and passed through to server jobs as normal job parameters.

Parameter values can be maintained through the DataStage Administrator.

Also possible is handling of environment specific parameters using $ENV values instead of $PROJDEF values.
 
Here is the full FAQ on this topic:

Creating project specific environment variables
- Start up DataStage Administrator.
- Choose the project and click the "Properties" button.
- On the General tab click the "Environment..." button.
- Click on the "User Defined" folder to see the list of job specific environment variables.

There are two types of variables - string and encrypted. If you create an encrypted environment variable it will appears as the string "*******" in the Administrator tool and will appears as junk text when saved to the DSParams file or when displayed in a job log. This provides robust security of the value.

Migrating Project Specific Job Parameters
It is possible to set or copy job specific environment variables directly to the DSParams file in the project directory. There is also a DSParams.keep file in this directory and if you make manual changes to the DSParams file you will find Administrator can roll back those changes to DSParams.keep. It is possible to copy project specific parameters between projects by overwriting the DSParams and DSParams.keep files. It may be safer to just replace the User Defined section of these files and not the General and Parallel sections.

Environment Variables as Job Parameters
- Open up a job.
- Go to Job Properties and move to the parameters tab.
- Click on the "Add Environment Variables..." button.
- Set the Default value of the new parameter to "$PROJDEF".

When the job parameter is first created it has a default value the same as the Value entered in the Administrator. By changing this value to $PROJDEF you instruct DataStage to retrieve the latest Value for this variable at job run time.

If you have an encrypted environment variable it should also be an encrypted job parameter. Set the value of these encrypted job parameters to $PROJDEF. You will need to type it in twice to the password entry box.

Using Environment Variable Job Parameters
These job parameters are used just like normal parameters by adding them to stages in your job enclosed by the # symbol.
Database=#$DW_DB_NAME#
Password=#$DW_DB_PASSWORD#
File=#$PROJECT_PATH#/#SOURCE_DIR#/Customers_#PROCESS_DATE#.csv

*** Warning: the "View Data" button will not work in server or parallel jobs that use environment variables set to $PROJDEF or $ENV. This is a defect in DataStage. It may be preferable to use environment variables in Sequence jobs and pass them to child jobs as normal job parameters. Eg. In a sequence job $DW_DB_PASSWORD is passed to a parallel job with the parameter DW_DB_PASSWORD.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top