From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f7344,a08d3b69b39ca00b X-Google-Attributes: gidf7344,public X-Google-Thread: f8dc0,a08d3b69b39ca00b X-Google-Attributes: gidf8dc0,public X-Google-Thread: 1164f8,a08d3b69b39ca00b X-Google-Attributes: gid1164f8,public From: hoffman@xdelta.enet.dec.com (Stephen Hoffman) Subject: Re: Generating unique numbers Date: 1995/12/13 Message-ID: <4an5ur$ho0@nntpd.lkg.dec.com>#1/1 X-Deja-AN: 121731293 distribution: world references: <4aic03$3u1@cantua.canterbury.ac.nz> organization: Digital Equipment Corp reply-to: hoffman@xdelta.enet.dec.com (Stephen Hoffman) newsgroups: comp.databases.rdb,comp.sys.dec,comp.os.vms 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 ---------------------------------------------------------------------------