From: hoffman@xdelta.enet.dec.com (Stephen Hoffman)
Subject: Re: Generating unique numbers
Date: 1995/12/13 [thread overview]
Message-ID: <4an5ur$ho0@nntpd.lkg.dec.com> (raw)
In-Reply-To: 4aic03$3u1@cantua.canterbury.ac.nz
In article <4aic03$3u1@cantua.canterbury.ac.nz>, E.Havelaar@Regy.Canterbury.Ac.NZ (Ed Havelaar) writes:
:We have an RdB database on top of VAX VMS (soon to migrate to Alpha) for which
:I need to generate a unique account number whenever I create a new record. I
:wonder if anyone has any experience on what the best way to do this is.
:Options that have crossed my mind are:
You don't mention the frequency of this particular operation.
I use imbedded SQL; I read the "max id" value from the database, and
and write the (incremented) result back to the database.
EXEC SQL
SET TRANSACTION READ WRITE WAIT ISOLATION LEVEL SERIALIZABLE RESERVING
xxx_ID_TABLE FOR PROTECTED WRITE;
if (SQLCA.SQLCODE != 0) SQL$SIGNAL();
There are various suggestions and tradeoffs on this particular topic
discussed the Rdb manuals.
--
If you want to use a faster mechanism, read the ID value into a lock
value block and maintain it there -- this does not help you from a PC,
but it does work nicely across all nodes in a VMScluster. You'll need
to design the restart code to reload the value in the lock value block
from the highest known ID value present in the database -- this logic
is needed for the recovery after a system crash.
--
I don't recommend pursuing the RMS file services approach, nor the
volatile memory mechanism, mentioned in your original posting. Both
can be made to work, but they do not appear to have advantages over
storage in Rdb or storage in a lock value block.
------------------------------ Opinionative -------------------------------
Stephen Hoffman OpenVMS Engineering hoffman@xdelta.enet.dec.com
Insunt interdum menda in eo quod est efficax
---------------------------------------------------------------------------
next prev parent reply other threads:[~1995-12-13 5:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1995-12-11 5:00 Generating unique numbers Ed Havelaar
1995-12-12 5:00 ` Lilian Hobbs
1995-12-14 5:00 ` Albert Godfrind
1995-12-13 5:00 ` Stephen Hoffman [this message]
1995-12-14 5:00 ` Generating unique numbers, etc Ed Havelaar
1995-12-14 5:00 ` Norm Lastovica
1995-12-15 5:00 ` Lilian Hobbs
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox