Random Function

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

Post Reply
kennyapril
Participant
Posts: 248
Joined: Fri Jul 30, 2010 9:04 am

Random Function

Post by kennyapril »

Hi everyone,

I used random function in transformer to generate random numbers and after that I am sorting them in ascending order so that the particular rows linked to a particular random number will not be pulled same each time. i.e my requirement is each time I need to get different records to be pulled.

But for some reason the random numbers generated are same all the times, I mean the numbers are random but everytime I run the job generates the same numbers which are generated for the first time.

Suggest me what change do I need to do to change the numbers different each time I run the job.

Thank you!
Regards,
Kenny
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

Unfortunately, the parallel transformer doesn't provide an interface to the underlying randomizer seed functions srand() or srandom(). Use a column generator to create your random value and provide an integer seed value from a job parameter (you can create a timestamp-based one in a job sequence so that it is a different value each time you run the job).

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So, as you've seen, those random numbers are not truly random since the pattern repeats each time based on the "seed" or the intial starting value. I believe the term is 'psuedo-random', hang on.... yup: Pseudorandom Number Generator wiki entry.

As noted though, you have ways to "randomly" set the seed value each time the job runs so your values become more random-esque.
-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 »

I typically use the method described by James Wiles earlier.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply