Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Autonumber trigger
Dmitry Lesov wrote:
>
> I need to to write a trigger that duplicates Autonumber in MS Access -
> Id Field gets nextval from the sequence upon insert. But I don't know
> how to write a trigger that does that. Appreciate any help.
> Dmitry
You need both a sequence and a trigger. Here's an example of each.
CREATE SEQUENCE "MCHRISTO"."SEQ_TBL_C_C_SECCOLOR"
INCREMENT BY 1
START WITH 1
MAXVALUE 999999999
MINVALUE 1
CYCLE
CACHE 20
ORDER;
CREATE OR REPLACE TRIGGER "MCHRISTO".TRG_SEQ_TBL_C_C_SECCOLOR
BEFORE INSERT ON "MCHRISTO"."TBL_C_C_SECCOLOR" FOR EACH ROW
BEGIN
SELECT
SEQ_TBL_C_C_SECCOLOR.NEXTVAL INTO :NEW.ID FROM DUAL;
Metra Received on Mon May 14 2001 - 09:44:51 CDT