How to store the Values in the Environment 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

shivakumar
Participant
Posts: 31
Joined: Wed Mar 17, 2004 3:33 am

How to store the Values in the Environment Variables

Post 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
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

How are you initiating the job? i.e. via shell or sequence ?
shivakumar
Participant
Posts: 31
Joined: Wed Mar 17, 2004 3:33 am

Post 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
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Individual job - your method

Sequence - userVariables
shivakumar
Participant
Posts: 31
Joined: Wed Mar 17, 2004 3:33 am

Post 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
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post 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.
shivakumar
Participant
Posts: 31
Joined: Wed Mar 17, 2004 3:33 am

Post 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...
nagarjuna
Premium Member
Premium Member
Posts: 533
Joined: Fri Jun 27, 2008 9:11 pm
Location: Chicago

Post 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
Nag
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
nagarjuna
Premium Member
Premium Member
Posts: 533
Joined: Fri Jun 27, 2008 9:11 pm
Location: Chicago

Post by nagarjuna »

Better in what aspect ? :?:
Nag
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
nagarjuna
Premium Member
Premium Member
Posts: 533
Joined: Fri Jun 27, 2008 9:11 pm
Location: Chicago

Post by nagarjuna »

Point taken :)
Nag
shivakumar
Participant
Posts: 31
Joined: Wed Mar 17, 2004 3:33 am

Post 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
shivakumar
Participant
Posts: 31
Joined: Wed Mar 17, 2004 3:33 am

Post 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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply