Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle sequence problem
> I need to solve a problem with Oracle sequence-trigger (for generating
> an "next" value). For empty table everything works fine, but when you
> are about to issue "insert" statement for a table with previously loaded
> data in it (say from a .dat file), the next value goes to 1, instead to
> the next largest in the column. E.G.You have a table with a column that
> has 10 records from 1 to 10. When you execute insertinto.....values...
> it creates as a next value 1 instead of 11, next 2 instead of 12 and so
> on.
>
> Any suggestions?
>
You may not be able to do it using a sequence.
create a trigger before insert
in this trigger you generate your own sequence like
select max(<colname>)+1 into Sequence from <tablename>
Regards
Nicolas Bronke
Received on Tue Oct 26 1999 - 04:40:57 CDT