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

From Scott Marlowe
Subject Re: how to prevent generating same clipids
Date
Msg-id 1144787789.32269.95.camel@state.g2switchworks.com
Whole thread Raw
In response to Re: how to prevent generating same clipids  (v.suryaprabha@gmail.com)
List 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

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.

pgsql-general by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: how to prevent generating same clipids
Next
From: Simon Riggs
Date:
Subject: Re: execution plan : Oracle vs PostgreSQL