Page 1 of 1

Random Function

Posted: Mon Jul 09, 2012 2:38 pm
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!

Posted: Mon Jul 09, 2012 4:22 pm
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,

Posted: Mon Jul 09, 2012 4:55 pm
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.

Posted: Mon Jul 09, 2012 4:57 pm
by ray.wurlod
I typically use the method described by James Wiles earlier.