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

From Ragnar
Subject Re: how to prevent generating same clipids
Date
Msg-id 1144788307.2809.4.camel@localhost.localdomain
Whole thread Raw
In response to Re: how to prevent generating same clipids  (v.suryaprabha@gmail.com)
List pgsql-general
On mán, 2006-04-10 at 22:43 -0700, 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:
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



pgsql-general by date:

Previous
From: Simon Riggs
Date:
Subject: Re: execution plan : Oracle vs PostgreSQL
Next
From: "Magnus Hagander"
Date:
Subject: Re: How to import a CSV file (originally from Excel) into a Postgresql 8.0.7 database