Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Advice please - Sequences, how do you use them?
Try using a Trigger on the table just before inserting a new row e.g.
Note that the Sequence will not necessarily be exactly sequential, but will
be unique. It depends on if the Sequence cached and other if the transaction
committed.
CREATE OR REPLACE TRIGGER trig_UserTable_ID
BEFORE INSERT ON UserTable
FOR EACH ROW
DECLARE
new_id NUMBER;
BEGIN
SELECT deq_UserTable_ID.NEXTVAL INTO new_id FROM dual;
:new.UserTable_ID := new_id;
END;
Carl Sarelius wrote in message <35c50be2.0_at_139.134.5.33>...
Hi,
I'm new to Pers Oracle 8 (and Oracle in general) and I'm after some advice.
For an assignment I have created a number of tables and put them in a project. Each of these tables has a primary key identified. To ease data input (at this stage through Navigator) I found a reference to the "sequence" statement and created a sequence with the aim of automatically creating the next number when inputting data.
My question is - how do I use it? My manual is not so clear on the method of execution. Also does the primary key attribute that the sequence will update need to be of a specific data type?
Advice appreciated.
--
Carl Sarelius
Carl.Sarelius_at_bigpond.com
Melbourne, Australia
Received on Wed Aug 05 1998 - 01:13:25 CDT
![]() |
![]() |