From: Scott Marlowe <smarlowe@g2switchworks.com>
To: Shavonne Marietta Wijesinghe <shavonne.marietta@studioform.it>
Cc: pgsql-sql@postgresql.org
Subject: Re: Serial
Date: Tue, 03 Apr 2007 09:17:19 -0500
Message-ID: <1175609839.22459.3.camel@state.g2switchworks.com> (raw)
In-Reply-To: <008301c775d1$4b224420$1102a8c0@dream>
References: <008301c775d1$4b224420$1102a8c0@dream>
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?
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: smarlowe@g2switchworks.com, shavonne.marietta@studioform.it
Subject: Re: Serial
In-Reply-To: <1175609839.22459.3.camel@state.g2switchworks.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox