Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle sequence problem

Re: Oracle sequence problem

From: Nicolas Bronke <newsgroup_at_trinity.de>
Date: Tue, 26 Oct 1999 11:40:57 +0200
Message-ID: <38156943_1@news2.prserv.net>

> 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

Original text of this message

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