> Does anyone know how to randomly generate a nine
> digit
> number that is always unique?
Bob:
Having seen the various reponses to this question it's
not clear if you're trying to solve the problem of
getting unique IDs for a table (in which case AUTONUM
is the way to go) or you are trying to solve the
problem of unique IDs across multiple instances of the
same database on different machines.
If the later, you have two choices:
If you have control of all copies of the database
(that is, they are all run by people in your own
organization) then you can stick a database serial
number in a standalone table in the database, and put
this number on the beginning of all AUTONUM generated
IDs. R:Base helps you do this with a very flexible
AUTONUM generation command -- you can specify a text
prefix for text AUTONUM columns.
If you _don't_ control all copies of the database,
then you will have to go with a GUID, variously
reported to stand for Globally Unique ID or Guaranteed
Unique ID. These are generally created by using the
ID on your network card along with some pseudo-random
information from your machine (CPUID, Clocktime, etc).
Because network card IDs are unique across the
universe (at least, the known universe) the ID
generated on one computer will never be generated on
another.
There are problems with GUIDs. First, they're large
(too large to be stored in any common integer type)
and you don't want to use large strings for indexes.
Secondly, they can contain the NULL character (ASCII
0) which makes them difficult to treat as strings.
All that said, it should be relatively easy to write
an R:Base UDF that would generate GUIDs using one of
the standard algorithms and I rather suspect that RBTI
would consider the request if you felt that they were
needed.
--
Larry
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/