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 assign a new value when insert a new record

Re: auto assign a new value when insert a new record

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Thu, 06 Jan 2000 07:16:47 -0500
Message-ID: <9s197ssjo2tfke364cg2n95hef87q2r0sa@4ax.com>


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

Original text of this message

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