Re: how to prevent generating same clipids

From: "Ian Harding" <iharding(at)destinydata(dot)com>
To: "v(dot)suryaprabha(at)gmail(dot)com" <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 21:00:19
Message-ID: 725602300604111400s3b01792ei1378b9c68533129a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

This problem has been solved, by the use of sequences. If you can't
use them as a default, you can use them instead of

MAX(clipid)

You would use

NEXTVAL(clipid_seq)

assuming you had first done

CREATE SEQUENCE clipid_seq;
SELECT SETVAL('clipid_seq', (select MAX(clipid) from whatevertable));

This will guarantee no duplicates. It will not guarantee no missing values.

On 10 Apr 2006 22:43:16 -0700, v(dot)suryaprabha(at)gmail(dot)com
<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
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Magnus Hagander 2006-04-11 21:13:06 Re: How to import a CSV file (originally from Excel) into a Postgresql 8.0.7 database
Previous Message Ragnar 2006-04-11 20:45:07 Re: how to prevent generating same clipids