Re: how to prevent generating same clipids

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:36:29
Message-ID: 1144787789.32269.95.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

Addendum:

Note that you can also set the default for the clipid column to be the
nextval('sequencename') at the same time, then if anyone DOES insert a
row without getting the nextval() first, it'll still give them the
proper value.

Note that a "serial" type is actually just an int with a default and a
dependency.

Also, you really should have a primary key or unique index with not null
attribute on the clipid column as well, just to be safe. PK is about
the same as unique & not null, just that foreign references aren't
automatic, but I get the feeling foreign keys aren't playing a role in
your schema just now.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ragnar 2006-04-11 20:45:07 Re: how to prevent generating same clipids
Previous Message Scott Marlowe 2006-04-11 20:34:16 Re: how to prevent generating same clipids