Re: Q: Machine generated keys
Date: Mon, 13 Mar 1995 17:45:19 GMT
Message-ID: <1995Mar13.174519.25538_at_ucl.ac.uk>
In article <Pine.SUN.3.91.950303084950.20086C-100000_at_seatimes>, Steve Butler <sbut-is_at_seatimes.com> says:
>
>
>On 2 Mar 1995, Steve wrote:
>> I have a requirement to find the next available value for a
>> machine generated primary key in a multi-user environment for a
>
>I let ORACLE generate the sequence numbers. Look at the CREATE SEQUENCE
>syntax. The application programmers can issue a SQL statement to get the
>value and ORACLE will ensure that only one user gets any particular value.
>
Or even try putting this in as a Before Insert Row trigger on the base table:
Declare
SqcValue Number(8);
BEGIN
Select Sqc_Dept_Id.NextVal into SqcValue from Dual;
:new.Dept_ID:=SqcValue;
END;
In this case the trigger grabs the next sequence ID from the sequence Sqc_Dept_ID
and drops it into the Dept_ID field before it generates the row... Works for me!
Tom
tom_at_safety.ucl.ac.uk - College Fire Officer and Office DBA & Systems Designer
- I make the coffee too most days!
Received on Mon Mar 13 1995 - 18:45:19 CET