Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: auto assign a new value when insert a new record
A copy of this was sent to "Mike Ng" <mike_at_email.tech-trans.com>
(if that email address didn't require changing)
On Thu, 6 Jan 2000 17:36:57 +0800, you wrote:
>Hi all,
>
>I use the Power Builder connect to Oracle 8i. Now I want when I insert a new
>record, the database will automatically assign a new value to the field of
>new record except using sequence. Anyone can help. Thanks a lot.
>
>Regards,
>Mike
>
you can use a trigger to do this:
create or replace trigger my_trigger
before insert on T for each row
begn
select my_sequence.nextval into :new.the_column from dual;
end;
/
--
See http://osi.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'...
Current article is "Part I of V, Autonomous Transactions" updated June 21'st
Thomas Kyte tkyte_at_us.oracle.com Oracle Service Industries Reston, VA USA
Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Thu Jan 06 2000 - 06:16:47 CST