Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Creating Sequence for Auto Number
hello
After you have created your sequence, you need to create a insert trigger on
the table where you want this incrementation, like this one:
CREATE SEQUENCE sequencename
INCREMENT BY 1;
CREATE OR REPLACE TRIGGER X
BEFORE INSERT
ON your tablename
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
Begin
SELECT sequencename.NEXTVAL
INTO :new.ID
FROM DUAL;
End;
Kukin Frane
<jkipp_at_mbna.com> a écrit dans le message news:
8vbjgc$hbc$1_at_nnrp1.deja.com...
> I am trying to create a sequence to auto number a column in a table.
> There is a small section on it in the ORacle book I am reading but it
> is not detailed enough for me to try it.
> I know I have to use the 'create sequence' command and something called
> the NextVal thingie.
> Would I have to create some sort of trigger(something else I don't know
> how to do) to tell the data to increment on say an insert, update?
>
> Thanks for any help
>
> Jim
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Mon Nov 27 2000 - 04:01:32 CST