From: | Scott Marlowe <smarlowe(at)g2switchworks(dot)com> |
---|---|
To: | v(dot)suryaprabha(at)gmail(dot)com |
Cc: | pgsql general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: how to prevent generating same clipids |
Date: | 2006-04-11 20:34:16 |
Message-ID: | 1144787656.32269.91.camel@state.g2switchworks.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, 2006-04-11 at 00:43, v(dot)suryaprabha(at)gmail(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Marlowe | 2006-04-11 20:36:29 | Re: how to prevent generating same clipids |
Previous Message | Richard Jones | 2006-04-11 20:15:30 | Re: SQL ASCII encoding |