Path: news.easynews.com!newsfeed1.easynews.com!easynews.com!easynews!newsfeeds.sol.net!upp1.onvoy!onvoy.com!nntp1.phx1.gblx.net!nntp.gblx.net!nntp.gblx.net!news.hgc.com.hk!not-for-mail
From: "HK Chang" <REMOVETHIS_hkchang@bigfoot.com>
Newsgroups: comp.databases.oracle.server
Subject: Re: How can I ceate a table primary key that auto increase by itself like access table id key ?
Date: Mon, 3 Mar 2003 16:04:06 +0800
Organization: HGC Boardband
Lines: 27
Message-ID: <b3v2us$mv9$1@news.hgc.com.hk>
References: <b3uqim$1hck$1@mail.cn99.com>
NNTP-Posting-Host: 203.184.192.192
X-Trace: news.hgc.com.hk 1046679325 23529 203.184.192.192 (3 Mar 2003 08:15:25 GMT)
X-Complaints-To: abuse@net-yan.com
NNTP-Posting-Date: Mon, 3 Mar 2003 08:15:25 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Xref: newsfeed1.easynews.com comp.databases.oracle.server:178220
X-Received-Date: Mon, 03 Mar 2003 01:08:44 MST (news.easynews.com)

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@163.com> wrote in message
news:b3uqim$1hck$1@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 ?
>
>


