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: How can I ceate a table primary key that auto increase by itself like access table id key ?

Re: How can I ceate a table primary key that auto increase by itself like access table id key ?

From: Giovanni Azua <bravegag_at_hotmail.com>
Date: Mon, 3 Mar 2003 10:57:25 +0100
Message-ID: <b3v93b$1q697o$1@ID-114658.news.dfncis.de>


You can optimize this slightly...

CREATE OR REPLACE TRIGGER CHR_MAS_INS_TRIG BEFORE INSERT ON CHR_MAS
FOR EACH ROW
BEGIN
  SELECT CHR_MAS_SEQ.NEXTVAL
  INTO :NEW.ID FROM DUAL;
END;
/

This sequence/trigger process is already slow, (find my mail above) imagine adding several copying/copying layers...

Regards,
Giovanni

PS: Britney Spears changed dancing by working with Oracle??? ;-)

"HK Chang" <REMOVETHIS_hkchang_at_bigfoot.com> wrote in message news:b3v2us$mv9$1_at_news.hgc.com.hk...
> Add a sequence, then create trigger to update the key.
>
> Just like:
> CREATE SEQUENCE CHR_MAS_SEQ START WITH 1 NOCACHE;
>
> CREATE OR REPLACE TRIGGER CHR_MAS_INS_TRIG
> BEFORE INSERT ON CHR_MAS
> FOR EACH ROW
> DECLARE
> SEQ_VAL NUMBER;
> BEGIN
> SELECT CHR_MAS_SEQ.NEXTVAL
> INTO SEQ_VAL FROM DUAL;
> :NEW.ID := SEQ_VAL;
> END;
> /
>
> "Britney Spears" <deboer76_at_163.com> wrote in message
> news:b3uqim$1hck$1_at_mail.cn99.com...
> > How can I ceate a table primary key that auto increase by itself like
> access
> > table id key ?
> > Is there any nature support on Oracle ?
> >
> >
>
>
Received on Mon Mar 03 2003 - 03:57:25 CST

Original text of this message

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