| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
|  |  | |||
Home -> Community -> Usenet -> c.d.o.server -> Re: Sequence
In article <8743h2$se4_at_nntpa.cb.lucent.com>, "Gary Knopp" <gknopp_at_ascend.com> wrote:
>
 create sequence t_seq
   start with 1000
   increment by 1;
2) create the table 't':
create table t (seq number, col2 number);
describe t
Name Null?Type ------------------------------- -------- ---- SEQ NUMBER COL2 NUMBER
3)Create a trigger to fire before the insert on table 't':
  create or replace trigger trig
  before insert on t
  for each row
  begin
   select  t_seq.nextval into :new.seq from dual;
  end;
4) Now, when an insert occurs on table 't' this
trigger 'trig' will automatically get called and will update the 'seq' column with the next value in sequence 't_seq'.
-cheers
  DW
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Mon Jan 31 2000 - 00:00:00 CST
|  |  |