Re: how to prevent generating same clipids

From: Ragnar <gnari(at)hive(dot)is>
To: v(dot)suryaprabha(at)gmail(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: how to prevent generating same clipids
Date: 2006-04-11 20:45:07
Message-ID: 1144788307.2809.4.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On mán, 2006-04-10 at 22:43 -0700, 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:
CREATE SEQUENCE clipid_seq
START WITH somehighenoughnumber

now use that when you allocate ids.
i.e. instead of
SELECT 1+max(clipid) FROM yourtable
do:
SELECT nexval(clipid_seq)

gnari

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ian Harding 2006-04-11 21:00:19 Re: how to prevent generating same clipids
Previous Message Scott Marlowe 2006-04-11 20:36:29 Re: how to prevent generating same clipids