Re: how to prevent generating same clipids

Поиск
Список
Период
Сортировка
От Scott Marlowe
Тема Re: how to prevent generating same clipids
Дата
Msg-id 1144787656.32269.91.camel@state.g2switchworks.com
обсуждение исходный текст
Ответ на Re: how to prevent generating same clipids  (v.suryaprabha@gmail.com)
Список 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 по дате отправления:

Предыдущее
От: Richard Jones
Дата:
Сообщение: Re: SQL ASCII encoding
Следующее
От: Scott Marlowe
Дата:
Сообщение: Re: how to prevent generating same clipids