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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Auto Sequencing When Insert

Re: Auto Sequencing When Insert

From: Nuno Guerreiro <nuno-v-guerreiro_at_telecom.pt>
Date: Fri, 10 Jul 1998 14:15:56 GMT
Message-ID: <35a6215d.16974137@news.telecom.pt>


On Fri, 10 Jul 1998 17:53:43 +0800, "Kenneth Xu" <xu_dong_at_irel.com.sg> wrote:

>Hi all,
>
>---------------------------------
>create table TestTable(
> UserID number(9),
> Name char(50)
>);
>
>create sequence TestSeq;
>
>create trigger Test_BeforeInsert
>before insert on TestTable for each row
>begin
> if :new.UserID is null then
> :new.UserID := TestSeq.nextval;
> end if;
>end;
>------------------------------
>
>
>It is very much appreciated if somebody point me a direction.
>
>TIA,
>
>Ken.
>
>

replace the body of the trigger with the following code:

if :new.UserID is null then

        select TestSeq.nextval into :new.UserID from dual; end if;

Hope this helps,

Nuno Guerreiro Received on Fri Jul 10 1998 - 09:15:56 CDT

Original text of this message

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