Update Environemt Variables

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Pavan_Yelugula
Premium Member
Premium Member
Posts: 133
Joined: Tue Nov 23, 2004 11:24 pm
Location: India

Update Environemt Variables

Post by Pavan_Yelugula »

Hi All
I needed to write some functionality where i needed to update the environemt variables in my Job stream.
I read through the Advanced Parallel Developer Guide..Job Development Kit and some posts in IT Toolbox. I finally figured out and wrote this c++ code

Code: Select all

#include <stdlib.h> 
#include <stdio.h> 
#include "/opt/atlas/IBM/InformationServer/Server/DSEngine/include/dsapi.h"

char * UpdateEnv(char *Projname, char *EnvVarName, char *Value)
{ 
int DSSetEnvVar(DSPROJECT Projname,char *EnvVarName,char *Value); 
char* OutStr; 
OutStr=Value;
return OutStr;
} 
I wrote a Parallel routine linking the .o file and i used it in my job and the job seems to be running fine but when i see the output i don't see the environemt variable updated...

my DSSetEnvVar(DSPROJECT Projname,char *EnvVarName,char *Value);
doesn't seems to be working....

Is there something i am missing in here

Any inputs will be really helpful

Thanks
Pavan
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Re: Update Environemt Variables

Post by ArndW »

Pavan_Yelugula wrote:...doesn't seems to be working...
Could you narrow down what isn't working? Is it the call giving an error or that the env variable isn't being changed? Add a call to DSLogWarn (I don't recall the API name) to see if the routine is actually being entered.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I'm curious why you "need" to do this, care to share? Perhaps there is a more better solution to whatever problem you are trying to solve.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

What is your plan for

Code: Select all

int DSSetEnvVar(DSPROJECT Projname,char *EnvVarName,char *Value); 
?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You don't actually seem to have invoked the DSSetEnvVar() function.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Post by mdbatra »

chulett wrote:I'm curious why you "need" to do this, care to share? Perhaps there is a more better solution to whatever problem you are trying to solve.
I was trying to achieve the same result(updating an environment variable) using the same method as described above by pavan but couldn't get it. I am now looking to do it using a job control but can't find any environment parameter setting BASIC function in BASIC guide.

Could you please share the alternative approache(s).
Rgds,
MB
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The fix to your parallel routine is trivial - you declared the function DSSetEnvVar to return an int result, but you never actually invoked the function.

There is no function for setting an environment variable from DataStage BASIC, but you can execute the TCL command

Code: Select all

ENV SET name=value
or an equivalent operating system shell command.

I recommend using Perform rather than calling DSExecute in this case, because Perform executes in the same shell.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Still curious why the perceived need to update environment variables... to what purpose?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

chulett wrote:Still curious why the perceived need to update environment variables... to what purpose?
Curiosity exterminated the Dalek's cat.
:lol:
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Pavan_Yelugula
Premium Member
Premium Member
Posts: 133
Joined: Tue Nov 23, 2004 11:24 pm
Location: India

Post by Pavan_Yelugula »

Hi Chulett
The Updation of environment variables is for our surrogate key approach as outlined below

http://it.toolbox.com/blogs/dw-soa/surr ... -way-22482

Hope this clarifies...

Thanks
Pavan
Pavan_Yelugula
Premium Member
Premium Member
Posts: 133
Joined: Tue Nov 23, 2004 11:24 pm
Location: India

Post by Pavan_Yelugula »

Ray
Thanks a lot for pointing that...I am really novice on c++ and didn't realise that.

I have improvised my code as follows

Code: Select all

#include <stdlib.h> 
#include <stdio.h> 
#include "/opt/atlas/IBM/InformationServer/Server/DSEngine/include/dsapi.h"

char * UpdateEnv(char *Projname, char *EnvVarName, char *Value)
{ 
DSPROJECT ABC=DSOpenProject(Projname);
DSSetEnvVar(ABC,EnvVarName,Value); 
char* OutStr; 
OutStr=Value;
return OutStr;
} 
I am able to compile my job and i called the routine in my transformer but when it is running it is aborting with the following error..

Code: Select all

Transformer_3: Failed to load the library "V0S3_ParallelRoutineTest_Transformer_3.so"; either the directory containing the library file
is not on the library search path, or the library was compiled on a system
that is incompatible with this system: Could not load "V0S3_ParallelRoutineTest_Transformer_3": /opt/atlas/IBM/InformationServer/Server/Projects/Atlas_ETL/RT_BP882.O/V0S3_ParallelRoutineTest_Transformer_3.so: undefined symbol: DSOpenProjectEx.
I am not sure why it is pointing me to DSOpenProjectEx....I checked the dsapi.h file and it has a function with DSOpenProjectEx(Int,char). I tried to use it in my c++ code instead of DSOpenProject but i still get the same abort

Any inputs will be really helpful
Thanks
Pavan
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Typically that error comes when the object code isn't linked correctly, and/or when the function definition doesn't match the code. Specifically:
- declare it as an object
- declare it with 3 arguments of char*
- declare it with a char* return type
- declare it with "external subroutine name" of "UpdateEnv"
- make sure the library path goes all the way to the UpdateEnv.o
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Pavan_Yelugula wrote:Hi Chulett
The Updation of environment variables is for our surrogate key approach as outlined below

http://it.toolbox.com/blogs/dw-soa/surr ... -way-22482

Hope this clarifies...
Hmmm... it does, thanks. Working routine code should really have been posted along with it.
-craig

"You can never have too many knives" -- Logan Nine Fingers
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Post by mdbatra »

ArndW wrote:Typically that error comes when the object code isn't linked correctly, and/or when the function definition doesn't match the code. Specifically:
- declare it as an object
- declare it with 3 argume ...
Hi ArndW,
I am working on an exactly same task.I declared the routine as an object file with 3 arguments but still getting the same error as mentioned above.
Please help in finding the cause.

Thanks in advance !!!
Rgds,
MB
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I'm not sure what your problem is. Do you still get a runtime error?
Post Reply