Hi, Gérald,
>Its 9,999,999 + 1 , Dont forget the '0000000' :)
Right. :)
>Its the 'random' part of the equation that ring a bell.
>
>10 millions seem to be a big number, but if you generate random numbers periodically, chances are relatively high that you generate the same number again. You have to check if the number exist each time you generate a new one.
This is where I like David and Sergey's suggestion so much--generate the keys first, and then discard them from a pool (or mark them used) as they are used.
>If you introduce a sequential part in your number, ie: derive a number from a date, you only have to check for replicate for the current day. For example you can use date()-date(2000,1,1) to get 4 digits that was unique for the current day. This let 3 digits (1000 numbers) for the current day.
I'd considered using part of the date embedded in the digit, but it doesn't really gain me much. Using the pool idea ahead is nice, though it does take some getting used to (for me) since I always think of creating records only when they're needed.
>
Thanks for your ideas, and I'm sure that readers will find it helpful, too.
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only