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

Home -> Community -> Usenet -> c.d.o.server -> Re: Using Sequence and Trigger for Unike fields

Re: Using Sequence and Trigger for Unike fields

From: Alton Ayers <altona_at_ditw.com>
Date: Mon, 13 Jul 1998 12:59:06 -0400
Message-ID: <35AA3CDA.96C8DA9@ditw.com>


You need to do

    IF (:new.usrid IS NULL) THEN

        SELECT USRID_SEQ.next_val
          INTO :new.usrid
          FROM dual;


Eric Jodoin wrote:

> Hi,
>
> I am trying to create a sequence and a trigger to make afield in my table
> kind of auto increment. every time a new record is created, a nuw id is
> inserted in the id field. I got tthe Sequence going easilly but I can't
> seem to be able to create a Trgger without getting the following error:
>
> MGR-00073: Warning: TRIGGER ¨se.css_user created with compilation errors
>
> The following code is run:
>
> DROP SEQUENCE "CSS_User"."USRID_SEQ" ;
>
> CREATE SEQUENCE "CSS_User"."USRID_SEQ"
> INCREMENT BY 1 NOMAXVALUE MINVALUE 1
> NOCYCLE CACHE 20 NOORDER ;
>
> CREATE OR REPLACE TRIGGER "CSS_User".UserAccess_Bit
> BEFORE INSERT ON "CSS_User"."USERACCESS"
> FOR EACH ROW
> BEGIN
> IF (:new.usrid IS NULL) THEN
> :new.usrid := USRID_SEQ.next_val
> end ;
>
> Please can you help ?
>
> Eric
> eric_at_jodoin.com
Received on Mon Jul 13 1998 - 11:59:06 CDT

Original text of this message

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