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: E.Havelaar@Regy.Canterbury.Ac.NZ (Ed Havelaar) Subject: Re: Generating unique numbers, etc. Date: 1995/12/14 Message-ID: <4aq3kt$nia@cantua.canterbury.ac.nz>#1/1 X-Deja-AN: 121826552 references: <4aic03$3u1@cantua.canterbury.ac.nz> content-type: Text/Plain; charset=US-ASCII organization: Information Services Section, University of Canterbury mime-version: 1.0 newsgroups: comp.databases.rdb,comp.sys.dec,comp.os.vms I've had a fair number of responses to my request below, and since not many of them seem to have turned up in the newsgroups, I thought I'd post a quick summary (and another question). First my question: Suppose I have a program that takes ages to run and keeps a read-only transaction open for its duration (e.g. to perform calculations on all 100000 records in a table), Every now and again, I want to assign an account number. This involves starting a read-write transaction for as short a time as possible. How can I do this without terminating my hours-long read-only transaction and somehow figuring out where and how to recommence it? Now my original question, and a bit of a summary. > >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. The general consensus seems to be: (1) Triggers would work, sort of. This doesn't really tell me what code to put in the trigger though -- I understand triggers are just a way of automatically executing some code on (say) an insert operation, so it would be handy for ODBC clients. I got the impression from a number of people that triggers are not overly fast, and we're looking at a peak load of about 400 inserts per hour, so I doubt this is the way to go. (2) Getting Max(Acc_No)+1 from a table is too slow. (3) Better to store the next available number in a table of its own, and have each application lock and increment it when it needs a new one. A few suggested the "Jerry Leichter" approach of splitting the available numbers into blocks with one record governing assignments from each block, and then using some random number to figure out which record to lock. We probably don't have enough load to justify bothering with the added complexity. (4) Nobody seemed to think there was any great advantage in using RMS files. ______________________________________________________________________ Eduard E Havelaar | The fool says in his heart, Information Services Section | "there is no God"... University of Canterbury | Christchurch, New Zealand | - Psalm 14:1