Do Persistent Variables exist in DataStage 6?

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
patonp
Premium Member
Premium Member
Posts: 110
Joined: Thu Mar 11, 2004 7:59 am
Location: Toronto, ON

Do Persistent Variables exist in DataStage 6?

Post by patonp »

I would like to use a variable that can be referenced or modified between rows that are processed by a job. Does the concept of persistent variables exist in DataStage?

Thanks,

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

Post by chulett »

Sure. As long as you are staying within a single Transfomer - Stage Variables should fill the bill. Check your online help.

Across Transformers in a Job you need to write custom routines that leverage COMMON storage. Again, read up on them in your documentation as there are some pretty big caveats to using this approach.
-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 »

The easiest and cheapest "persistent variable" for use between adjacent Transformer stages (or any active stage types) is an extra column on the link.

The job itself has a "user status area" which acts like a single variable accessible from anywhere within the job. Its value is set using the DSSetUserStatus function, and retrieve using the DSGetJobInfo function (with DSJ.ME as the job handle if in the current job). Actually, the job's user status area is in fact disk-based, so that it persists even after the job has finished.

Variables defined to be in a COMMON area are only accessible within the same process. Therefore, if you place a process boundary (a passive stage type or an inter-process stage) between your two active stages, they will run in separate processes. While this can achieve throughput gains due to pipeline parallelism, it means that you can't use COMMON variables.

The cost of using extra columns on links is miniscule. Go that way.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
patonp
Premium Member
Premium Member
Posts: 110
Joined: Thu Mar 11, 2004 7:59 am
Location: Toronto, ON

Post by patonp »

Thanks for the feedback.

Just to clarify - I would like to pass the values between rows, not between stages. For example, let's say I want to detect whether I've received 5 or more records with a specific value in a given column. Each time I detect that value in the incoming data, I would like to increment a counter by 1. After processing 100 rows, for example, my counter may have a value of 0 to 100, depending on how may rows matched the criteria I'm providing.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Stage Variable. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
patonp
Premium Member
Premium Member
Posts: 110
Joined: Thu Mar 11, 2004 7:59 am
Location: Toronto, ON

Post by patonp »

Doesn't a stage variable re-initialize as each record passes through the stage?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Only if you tell it to. :wink:

It's simple enough to keep its current value by assigning it to itself. For example, with one called MyVariable, use something like this in its derivation to only increment it when certain conditions are met:

Code: Select all

If X Then MyVariable + 1 Else MyVariable
That make sense? Stage Variables are very powerful, you'll find them very handy.
-craig

"You can never have too many knives" -- Logan Nine Fingers
patonp
Premium Member
Premium Member
Posts: 110
Joined: Thu Mar 11, 2004 7:59 am
Location: Toronto, ON

Post by patonp »

Wow. Can't believe I missed this one!

Thanks for the help,

Peter
Post Reply