Counter withing transform function

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
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I am a little confused by your subject, since it suggests you want to use a transform function. While this can be done, let me address a couple of ways to solve your problem without needing a function at all. I am also assuming that you are asking about server jobs rather than mainframe or parallel jobs.

In the Transformer stage there is a system variable available (called @INROWNUM) that counts the rows arriving on the main input link. Its value is 1 for the first row processed, 2 for the second row processed, and so on.

On each output link there is a similar counter, called @OUTROWNUM, which counts only the rows passing along that link, again starting from 1.

If you want to start from a value other than 1, or increment by some other value, then you can use a stage variable. The stage variable is initialized on the Transformer stage's properties window, and its derivation is handled within the Transformer stage's design canvas (you may have to enable visibility of stage variables). For example, to start from 100 and increment by 10, you might create a stage variable called MyCounter, initialize it to 100, and use as its derivation expression (MyCounter + 10).

If you do want to do something in a Routine (such as a transform function) you can use variables declared to be in a COMMON area of memory. Check out COMMON in the on-line help, and/or look at some of the SDK key management routines for examples of this technique. Variables in COMMON are automatically initialized to zero.


Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518
Post Reply