Re: how to prevent generating same clipids - Mailing list pgsql-general

From Scott Marlowe
Subject Re: how to prevent generating same clipids
Date
Msg-id 1144787656.32269.91.camel@state.g2switchworks.com
Whole thread Raw
In response to Re: how to prevent generating same clipids  (v.suryaprabha@gmail.com)
List pgsql-general
On Tue, 2006-04-11 at 00:43, v.suryaprabha@gmail.com wrote:
> Hi
>    Now we cannot change the field type. Because already our application
> is running and thousands of records are already entered. we are getting
> same no for clipid when 2 users are entering data at a time. so how to
> solve the problem

Create a sequence.
Set it's next id to something like "select max(clidid)+100" and start
using the sequence to get the next clipid from.

As long as the +100 is a big enough number that you won't have overrun
the sequence with the max(clipid) before you implement the code change.

You should be able to deploy the change to your app and the sequence in
the database at about the same time, or during a maintenance window I'd
assume.

Read up on nextval() and currval() before you set this in motion.
They're really quite an elegant solution to such issues.

pgsql-general by date:

Previous
From: Richard Jones
Date:
Subject: Re: SQL ASCII encoding
Next
From: Scott Marlowe
Date:
Subject: Re: how to prevent generating same clipids