Page 1 of 1

Generation of Ramdom Number

Posted: Wed Jan 07, 2009 2:13 am
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

Re: Generation of Ramdom Number

Posted: Wed Jan 07, 2009 4:24 am
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 ?

Posted: Wed Jan 07, 2009 6:10 am
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.