Page 1 of 2

How to store the Values in the Environment Variables

Posted: Wed Jul 01, 2009 11:45 pm
by shivakumar
Hi ,

I am having the PX job design as follows.

Oracle Stage--->LkpStage-->Oracle Stage.

When the Look up is filed I have to create the Reject file with Data and the Number of the Job Run.The reject file (Sequential File Stage) is having the file name as:

CutomerReject_`date +%d_%m_%Y_$MYVAL`

Here the MYVAL is an environment variable defined in the admin and I am setting the default value as 0.

In the before Job Routine I am executing the Unix command:

MYVAL=`expr $MYVAL + 1`.

My Requirement is when I ran this job 5 times then I have to generate 5 reject files with filename_Date_1.........filename_Date_5.

But I am unable to restore the Incremental Value in the Environment Variable.

How Can I store the Incremental value in the Environment Variable?

When I ececute the Job then is it possible to reset the Environment Variable to '0 ' in Data stage?

Can any one help me regarding this?

Thanks in advance....

Regards
Siva

Posted: Thu Jul 02, 2009 2:46 am
by Sainath.Srinivasan
How are you initiating the job? i.e. via shell or sequence ?

Posted: Thu Jul 02, 2009 2:55 am
by shivakumar
Hi ,

If it is the individual job then what is the solution?

If it is running from the sequence then what is the solution?

Thanks.
Siva

Posted: Thu Jul 02, 2009 4:40 am
by Sainath.Srinivasan
Individual job - your method

Sequence - userVariables

Posted: Thu Jul 02, 2009 5:52 am
by shivakumar
Hi ,

For Individual Job you have give as "Your Method".In my method I am unable to store the values in the Environmental variable that is my question?

If you know the answer then please revert me back...

Thanks
Siva

Posted: Thu Jul 02, 2009 6:24 am
by Sainath.Srinivasan
Siva,

I had started by attempting to understand your requirement and design.

Unfortunately your response does not assist.

So will leave it to others.

Posted: Thu Jul 02, 2009 6:30 am
by shivakumar
Sainath,

In the fisrt post onlly I mentioned I am having the problem to store the values for the Environment Variable.

What ever the responses you have given is stating that you are not at all read the complete problem. If i give the solutions to others then I can not give one line answers.

based on your response I am giving this...please dont give single line statements as answers..

Now wew can leave it to others...

Posted: Thu Jul 02, 2009 6:48 am
by nagarjuna
you can pass the variable at the run time .Make that variable job parameter and give that value at runtime .

MYVAL=`expr $MYVAL + 1`.

dsjob -run -param P_MYVAL=$MYVAL ......Try this n let us know

Posted: Thu Jul 02, 2009 7:23 am
by chulett
A much better solution would be to build a Sequence job with the Start/End Loop stages. Pass in the $Counter variable as a job parameter to use in your output filename. IMHO.

Posted: Thu Jul 02, 2009 9:39 am
by nagarjuna
Better in what aspect ? :?:

Posted: Thu Jul 02, 2009 9:43 am
by chulett
"Better" than the orignal method as it is easier to understand, simple to setup, is all in DataStage and actually works as an added bonus. :wink:

All this IMHO, of course.

Posted: Thu Jul 02, 2009 10:00 am
by nagarjuna
Point taken :)

Posted: Fri Jul 03, 2009 4:54 am
by shivakumar
Hi ,

While using the Start and End Loop we are getting the Counter Values.
As per the requirement I have to reset the Counter Value as Zero(0) for every day run.

How Can I achieve this in Data Stage?

If this we have to achieve by using Unix script then what are the steps we have to follow?

Please help me regarding this.

Thanks and Regards
Siva

Posted: Fri Jul 03, 2009 5:58 am
by shivakumar
Hi ,

One moer thing for each run I have to create a Reject file.If i set the Job in between Start and end loop I have to give the Values for From Step and To properties of the Start Loop Stage. I have given 1,1,1 it executes the job one time and the counter value is also 1.

If I executes the Sequence for second time on the same day then again the counter value is 1 only and my reject file created as _date_1 only.But this time I need the counter value as 2.

If I increase the Strart Loop Stage values as 1,1,5 then for a single run it generates 5 rejects file this can not matck the requirement.

Can any one help me regarding this..

Thanks in advance..
Siva

Posted: Fri Jul 03, 2009 7:14 am
by chulett
I don't know about anyone else, but now I'm confused as to what it is you are trying to do. :?

The assumption up to this point was that you needed to run your job five times in a row using different parameter values. Is that not the case? Are you saying it may need to run up to five times in a singleton fashion over the course of the day? That's completely different.

Please clarify what exactly it is that you need to do.