Environment Variables - Runtime $ENV

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
kavo
Participant
Posts: 7
Joined: Tue Apr 08, 2003 1:21 am

Re: Environment Variables

Post by kavo »

I had the same problem. I decided to go back to using standard job parameters instead.


Damien :?
Teej
Participant
Posts: 677
Joined: Fri Aug 08, 2003 9:26 am
Location: USA

Re: Environment Variables - Runtime $ENV

Post by Teej »

mharkema wrote: However, when I try to use $ENV as a value for my environment variable $TARGET_UID, DataStage replies with the following message:

Missing Parameters $TARGET_UID [$ENV]

How can I use a "dynamic" environment variable that is being looked up during runtime?
GetEnvironment() function does what you want if you are using the Transform stage within Parallel Extender. The advice by the previous poster is also good (and more flexible than this solution).

-T.J.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You need version 6.0 or later for the following.
When you create job parameters, there is a command button labelled "Add Environment Variable" on the Parameters page in the job properties window.
This opens a dialog in which all currently available environment variables are displayed. This is particularly useful for parallel jobs, since the operation of each of the APT... environment variables is documented in that window. You also (at the top of the tree view) have the opportunity to create a new environment variable.
gh_amitava
Participant
Posts: 75
Joined: Tue May 13, 2003 4:14 am
Location: California
Contact:

$ENV

Post by gh_amitava »

Hi,

Set your environment variables in dsenv file. Execute the dsenv file and restart your datastage server. in dsjob command prompt define your environment variables like this..

-param '$ENVRNAME=$ENV'

Regards
Amitava ghosh
rhettbutlernc
Charter Member
Charter Member
Posts: 14
Joined: Thu Dec 04, 2003 11:34 am

Post by rhettbutlernc »

I am trying to generate unique Sequence numbers using the Enviroment variables APT_PARTITION_COUNT and APT_PARTITION_NUMBER for my Parallel Jobs.

I added 'New Environment Varible' by specifying the 'Name' and 'Prompt' for these variables. ( eg: APT_PARTITION_COUNT and Partition Count).

I am using a Tranformer with 'GetEnvironment($APT_PARTITION_COUNT)'
and specified $ENV when I run the job...

When I run the get the following error message..

TestSurrKey: Missing Parameters $APT_PARTITION_COUNT [$ENV].

How should these 'APT_....' variables be treated. Should these be set in the dsenv file or anywhere else as well.

Thanks for all your help!!
trobinson
Participant
Posts: 208
Joined: Thu Apr 11, 2002 6:02 am
Location: Saint Louis
Contact:

Post by trobinson »

My understanding is that the environment variables can be set ONLY in dsenv. Fairly useless when multiple jobs within the same server need different values.
We are finding $environment variables useful as global parameters. By global I mean by project. These variables are set in the DSParams and can save time and effort when the same named parameters are used by different jobs in the same project.
One extremely frustrating aspect of this is that the dang things cannot be easily defined within a shared container. The shared container does edit checks on all parameters and WILL NOT ALLOW a $ in the parameter. The Shared Container parameter department at Ascential must have been on vacation when environment variables were discussed by the Job parameter department. There are two workarounds; either define the shared container functionality from within a job and then construct the shared container or hack the exported shared container .dsx and manually put the $ environment variables into the shared container.
Eric
Participant
Posts: 254
Joined: Mon Sep 29, 2003 4:35 am

Post by Eric »

My understanding is that the environment variables can be set ONLY in dsenv
As I understand, you can set them at a Project level using the Administrator, and thus you are not required to set them in the dsenv.
There are two workarounds; either define the shared container functionality from within a job and then construct the shared container or hack the exported shared container .dsx and manually put the $ environment variables into the shared container.
what about ...
You could create a normal named parameter in the shared container.
Then add the $EnvVariable to the job that contains the shared container. Then pass the $Variable into the Shared container parameter. (stage properties tab on shared container)
trobinson
Participant
Posts: 208
Joined: Thu Apr 11, 2002 6:02 am
Location: Saint Louis
Contact:

Post by trobinson »

You can't set them in the environment at job runtime and have them available to the job is what I meant.
Also I meant if you want the job parameter to be named the same as the env variable, you cannot do this in the shared container. Naturally, you can equate a $<name> to <name> if you want. I would prefer to limit the confusion caused by having multiple name parameters with different names actually mean the same thing.
rhettbutlernc
Charter Member
Charter Member
Posts: 14
Joined: Thu Dec 04, 2003 11:34 am

Post by rhettbutlernc »

I am trying to create the sequence numbers as per the discussion
viewtopic.php?t=60

When I give $ENV at runtime I am expecting the total number of nodes(4 in my case)

Here is the sequence I implemented:

1) Add a new Env variable APT_PARTITION_COUNT in the Administrator at the project level using 'Add New Environment variable'.

2) Design a job db2 --> xfm --> db2

3) Include the defined Parameter, in the job ( Edit --> Job properties --> Paramater --> Add Env Variable ( $APT_PARTITION_COUNT)

4) In the Tranformer stage derivaton: GetEnvironment($APT_PARTITION_COUNT)

I also tried the derivations $APT_PARTITION_COUNT and GetEnvironment($APT_PARTITION_COUNT) and the expression stays red. When it is compiled the job doesn't compile saying:

Error preprocessing Tranform Derivation.

5 ) But when I include the variable in quotes, 'GetEnvironment($APT_PARTITION_COUNT)', the job compiles but aborts saying "Missing Parameters $APT_PARTITION_COUNT [$ENV]"

Please let me know if I am missing something.... I guess it has something to do with the syntax
DSAlex
Participant
Posts: 1
Joined: Mon May 19, 2003 4:01 am
Location: Italy

Post by DSAlex »

Hi guys,

I've been running into the same problem with DS V7.1 and discovered that the $ENV clause can only be used when calling sequences:

If you have a job that has one (or more) parameters wich are defined as enviroment variables (in Administrator Module), assigning them the $ENV value will give you an error at runtime.
You have to call that job from a sequence from where you assign the value $ENV to the (environment) parameters, that way is fine and the dynamic value is retrieved all right.

I think this is due to fact that when a sequence calls a job, it first assigns values to the parameters by calling DSSetParam() routine wich works fine.
Probably this could work by calling your job from another job (from BASIC) using DSSetParam() to set params.

Enjoy. :lol:

Alessandro Cagnetti
NCR Italy, Teradata Division
Post Reply