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: HK Chang <REMOVETHIS_hkchang_at_bigfoot.com>
Date: Mon, 3 Mar 2003 16:04:06 +0800
Message-ID: <b3v2us$mv9$1@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 - 02:04:06 CST

Original text of this message

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