Re: Q: Machine generated keys
Date: 2 Mar 1995 12:20:32 GMT
Message-ID: <3j4d6g$50g_at_newstand.syr.edu>
In article <3j3ef1$5qa$1_at_mhade.production.compuserve.com>, Steve <70523.1016_at_CompuServe.COM> says:
>
>I have a requirement to find the next available value for a
>machine generated primary key in a multi-user environment for a
>high volume table. My problem is that I need to find the value
>for the key prior to allowing the system user to begin editing a
>new record. On a application's screen, the user will be
>attempting to do a multi table insert -- the primary key value is
>also the foreign key in several other tables.
>
>Because several users will be attempting to do the same type of
>inserts simultaneously, I need to be able to prevent other users
>from obtaining the same machine generated key.
>
>Has anyone had to do something similar? What was your approach?
>
>Sample code, or helpfull suggestions would be greatly
>appreciated.
>
>Thanks in advance.
>
>--
>-------------------------------------------------
>Stuck in the slow lane on the information superhighway.
Oracle provides a SEQUENCE object that allows you to SELECT the next unique value:
select my_sequence.nextval into :foo from DUAL;
The DUAL table is some sort of dummy table for retrieving such values. Feel free to contact me more on this topic as we are going to implement this feature in a system I'm working on.
Eric A. Stephens, Software Developer
CSC Technology Management Group
Syracuse, NY USA
eastephe_at_mailbox.syr.edu <MIME enabled>
http://web.syr.edu/~eastephe
Received on Thu Mar 02 1995 - 13:20:32 CET