Generation of Ramdom Number

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
bireswar.goswami
Participant
Posts: 33
Joined: Wed Sep 03, 2008 5:48 am
Location: Bangalore

Generation of Ramdom Number

Post by bireswar.goswami »

Hi All,
I have to produce random no as customer id for near about 60 mil customer records. The logic to generate the random no needs to be the following:

randomID = Double(floor(random() * 1000))
timeID = Long(currentTimeMillis())
Gen_ID = randomID (concatination) timeID
if (Length(Gen_ID) < 18 ) then
{
CUS_ID = Gen_ID
}
else
{
while (length(Gen_ID) < 18)
{
randomID = Double(floor(random() * 1000))
timeID = Long(currentTimeMillis())
CUS_ID = randomID (concatination) timeID
}


Friends it would be really a great help if some body can give me the way to generate this.

Thanks,
Bireswar
swarnkar
Participant
Posts: 74
Joined: Wed Jan 11, 2006 2:22 am

Re: Generation of Ramdom Number

Post by swarnkar »

[quote="bireswar.goswami"]Hi All,
I have to produce random no as customer id


Why you want to generate random number, to maintain Cust_Id to be unique or there is some other purpose ?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I wish I had DS on this machine, at least the documentaton; the function is either "RND()" or "RAND()" but I can't recall which. You can also SEED the series to ensure that you get reproduceable results. As asked before, if you wish to get unique customer IDs then using a random number generator is not the way to go as you will, at some point in time, get duplications.
You can either use a sequence (either from DataStage or from a database) or, if you wish pseudo-random customer numbers, at least keep a list of numbers used in a hashed file so you can avoid duplicates.
Post Reply