Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Auto Sequencing When Insert
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
![]() |
![]() |