Environment Variables

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
kaps
Participant
Posts: 452
Joined: Tue May 10, 2005 12:36 pm

Environment Variables

Post by kaps »

Hi

I am trying to read a environment variable and assign it to a local variable in transform stage. is that possible ? Basically, I have used env variable in my job it works but when I am trying to assign it to a local variable or port and store it in target as a field, it's not working ? any clues ???

Thanks
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Welcome aboard. :wink:

Typically, you define a Job Parameter and assign it the value of the environment variable. You then use it in your job like any other parameter.

You will, however, need to clarify what exactly this means before we can make any meaningful comments:
Basically, I have used env variable in my job it works but when I am trying to assign it to a local variable or port and store it in target as a field, it's not working ?
It works but it's not working? :? How are you currently 'using' it in your job and how are you trying to assign it to a 'local variable'? Specific examples would be good. Also include your DataStage version - 7 dot what? - as the way environment variables work have changed (for the better) in every 7.x release so far from what I recall.
-craig

"You can never have too many knives" -- Logan Nine Fingers
talk2shaanc
Charter Member
Charter Member
Posts: 199
Joined: Tue Jan 18, 2005 2:50 am
Location: India

Re: Environment Variables

Post by talk2shaanc »

kaps wrote:Hi

Basically, I have used env variable in my job it works but when I am trying to assign it to a local variable or port and store it in target as a field, it's not working ? any clues ???
reading the above part, of your thread, I feel that with local variable you mean Job Parameter and if i am correct, then I must tell you; that you cannot re-initialize a job parameter of a job, in one of the stages of the same job.
Job parameter are initialized in the begining while running the job. if you try to over-ride the value which was set earlier, it wont be re-initialzed and unfortunately even the datastage job wont return any error or warning message.It will be executed successfully.
Shantanu Choudhary
kaps
Participant
Posts: 452
Joined: Tue May 10, 2005 12:36 pm

Post by kaps »

Thanks for the replies. Data Stage Designer version 7.5.
Let me rephrase my question.
Actually what I am trying to do is to read an environment variable and assign the value of that
as a column and store that in my target.

Example

I have a environment variable called env1.

my job structure is like this.

source-->Transform-->Target

In my transform stage I am adding one column say Test ans assign env1 value to it.

Derivation Column Name
---------- -----------
#env1# Test

This is not working...

Expecting your reply

Thanks
ds_developer
Premium Member
Premium Member
Posts: 224
Joined: Tue Sep 24, 2002 7:32 am
Location: Denver, CO USA

Post by ds_developer »

Environment Variables are not used directly in a derivation. They are assigned to a job parameter and the job parameter is used in the derivation (or in other places). See the excellent FAQ in this forum.

John
kaps
Participant
Posts: 452
Joined: Tue May 10, 2005 12:36 pm

assignement ???

Post by kaps »

I have created the job parameter and assign env variable to it. used $PROJDEF in default value. Now when I assign this to a column I am getting an error.

I assigned it like this in derived column...

#env1#
#$env1#

But it throws an error ? What am I doing wrong ?

Thanks
ds_developer
Premium Member
Premium Member
Posts: 224
Joined: Tue Sep 24, 2002 7:32 am
Location: Denver, CO USA

Post by ds_developer »

Try using the job parameter name without the #'s.

John
kaps
Participant
Posts: 452
Joined: Tue May 10, 2005 12:36 pm

Post by kaps »

Thanks Guys...I got it...It's $env1
Post Reply