Rnd function always returns the same value

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
pnpmarques
Participant
Posts: 35
Joined: Wed Jun 15, 2005 9:27 am

Rnd function always returns the same value

Post by pnpmarques »

Hello!
I have created a Server Routine that has this single line:
Ans=Rnd(1000)

I tested this routine several times and it always generates a random number as expected.
BUT when I execute this routine inside a Transformer stage, for each job execution I always get the same number (513), it's not generating a random number...

I tested a simple job that loads 3 rows into a file with 1 column which Derivation is just the calling of the above routine. Everytime I run, it I always get the following:
513
175
308

Did anyone experienced something like this?
Any explanation why this routine has a differente behaviour when inside a Transformer stage?

Thank you!
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Read the DataStage BASIC manual about this function, and how the generator is seeded. You may need to create a before-stage subroutine to seed it off something variable like

Code: Select all

Date() * Time()
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I was thinking the same thing but it seems the seed is more applicable to the Randomize() function. Rnd(n) is supposed to generate a random number between 0 and n-1 rather than a series of 'pseudo-random' numbers.

Mind you, I haven't read the BASIC manual entry for this, only the online help.
-craig

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