Page 1 of 1

Environment Variables

Posted: Thu Jun 16, 2005 8:11 pm
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

Posted: Thu Jun 16, 2005 10:11 pm
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.

Re: Environment Variables

Posted: Fri Jun 17, 2005 3:46 am
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.

Posted: Fri Jun 17, 2005 8:50 am
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

Posted: Fri Jun 17, 2005 9:22 am
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

assignement ???

Posted: Fri Jun 17, 2005 10:59 am
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

Posted: Fri Jun 17, 2005 11:31 am
by ds_developer
Try using the job parameter name without the #'s.

John

Posted: Fri Jun 17, 2005 11:57 am
by kaps
Thanks Guys...I got it...It's $env1