On Sun, 19 May 2002, Joel Burton wrote:
> > I made the primary key
> >
> > "authkey" bigint DEFAULT trunc(random()*10^15) NOT NULL
> Be sure to build into your app some way of handling the error that will
> happen if a random primary key is already in the table -- resubmitting it
> should work fine (the odds of this happening twice become _extremely_
> unlikely, unless your table is very large)
If you know about how many rows you will be inserting, why not
build a table of random ints drawn from a finite pool without
replacement? Then, you just have to pick the next unused random
int from the random pool table to use in your other table. If
you get to the point where the table is exhausted (surely the
number of rows in the pool is less than the period), you just
add some more random ints.
> Anyone know off the top of their heads what the period for PG's random()
> function is?
Sorry, not I.
Gord
Matter Realisations http://www.materialisations.com/
Gordon Haverland, B.Sc. M.Eng. President
101 9504 182 St. NW Edmonton, AB, CA T5T 3A7
780/481-8019 ghaverla @ freenet.edmonton.ab.ca
780/993-1274 (cell)