Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: Autonumber trigger

Re: Autonumber trigger

From: metra christofferson <metra.christofferson_at_honeywell.com>
Date: Mon, 14 May 2001 07:44:51 -0700
Message-ID: <3AFFEF63.68F3A7F1@honeywell.com>

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;

END; Hope this is useful,

Metra Received on Mon May 14 2001 - 09:44:51 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US