Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 8A5239FB77A for ; Tue, 3 Apr 2007 11:17:40 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 05171-01 for ; Tue, 3 Apr 2007 11:17:24 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from exchange.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 3CE429FB733 for ; Tue, 3 Apr 2007 11:17:25 -0300 (ADT) Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; Tue, 3 Apr 2007 14:17:19 +0000 Received: from state.g2switchworks.com by mail.g2switchworks.com; 03 Apr 2007 09:17:19 -0500 Subject: Re: Serial From: Scott Marlowe To: Shavonne Marietta Wijesinghe Cc: pgsql-sql@postgresql.org In-Reply-To: <008301c775d1$4b224420$1102a8c0@dream> References: <008301c775d1$4b224420$1102a8c0@dream> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1175609839.22459.3.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Tue, 03 Apr 2007 09:17:19 -0500 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/31 X-Sequence-Number: 28031 On Tue, 2007-04-03 at 04:20, Shavonne Marietta Wijesinghe wrote: > Ok so i'm posting alot in the forums. Anyway for a change i have > another problem ^___^ > > I have a table that has a field n_gen serial NOT NULL > > ermm let me explain. I have 5 records inserted (n_gen = 1, 2, 3, 4, 5) > > At a surtain point i DELETE the record 2 and UPDATE the record 5 with > the n_gen 2. So now i have 4 records (n_gen = 1, 2 (EX 5), 3, 4) Upto > this point i'm ok. > > The problem is when i INSERT a new record. It takes the value n_gen = > 6 but i need it to take the value 5. It keeps a record of the delete > records. > > Is there anyway in PostgreSQL i can change it? or another progressive > that i can use for n_gen ?? Yes there is, and you generally shouldn't do it. There are issues with race conditions and misreferenced data that can happen when you try to reuse sequence numbers. Sadly, some poorly defined business processes require this. Are you required to have sequential numbers, or is just something that feels good / looks good?