Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Autoincrement
A copy of this was sent to buurd_at_my-deja.com
(if that email address didn't require changing)
On Thu, 14 Oct 1999 09:45:16 GMT, you wrote:
>Hi!
>I'm looking for a function in Oracle that would autoincrement an
>idcolumn so that every column gets it's own uniqe number. I'll looked
>at seqences but i don't understand how to automate the process so that
>for every new row there is a new (uniqe) number.
>
>Tia
create sequence myseq;
create or replace trigger my_trigger
BEFORE INSERT on MY_TABLE
for each row
begin
select myseq.nextval into :new.IDColumn from dual;
end;
/
is the way to do it in Oracle.
--
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 Oct 14 1999 - 07:21:18 CDT