Issue with Random() function
Moderators: chulett, rschirm, roy
Issue with Random() function
Hi All,
I have recently used Random() function to get random numbers generated from the Transformer. But it seems to be generating duplicate values, though I defined the Transformer to run in sequential mode. This is quite strange. Please let me know if anyone faced this or any workaround.
The problem with the duplicate values is that those values are going as the primary key into the DB and the job is failing due unique constraint voilation.
Thanks
I have recently used Random() function to get random numbers generated from the Transformer. But it seems to be generating duplicate values, though I defined the Transformer to run in sequential mode. This is quite strange. Please let me know if anyone faced this or any workaround.
The problem with the duplicate values is that those values are going as the primary key into the DB and the job is failing due unique constraint voilation.
Thanks
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
There's no reason a random number would not generate duplicates. They're random, after all. You can even work out the probability of it occurring, if there is a finite domain of values from which the random number can be selected.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Thanks Craig/Ray/v2kmadhav for the inputs. Working out the recurrence of numbers as Ray says, it will consume time. Since this random function in Datastage was swirling my head , I had to go with alternative implementation of involving the database. I will close this topic.
In general terms, random<>unique. Nevertheless, in my case, random is being exploited for uniqueness of the values.
And also surprisingly it generates the same duplicate random numbers for the consequtive runs. I am not sure why and it is strange. There should be some place in Datastage where it needs be reset so that it doesnt come up with the same number. Can any one try this with more number of rows (probability of duplicate numbers is more)?
In general terms, random<>unique. Nevertheless, in my case, random is being exploited for uniqueness of the values.
And also surprisingly it generates the same duplicate random numbers for the consequtive runs. I am not sure why and it is strange. There should be some place in Datastage where it needs be reset so that it doesnt come up with the same number. Can any one try this with more number of rows (probability of duplicate numbers is more)?
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
You can seed the random number generator in DataStage. I'd recommend something based on time (seconds since midnight, for example), possibly multiplied by numeric date components.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.