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-10 21:21:49
Message-ID: 1144704108.32269.73.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 2006-04-10 at 07:02, v(dot)suryaprabha(at)gmail(dot)com wrote:
> Hi All,
>
> I am having the clipid field in my table.In my application i am taking
> Max(clipid) and inserting it into the table by incrementing that max
> value. so there is a problem when 2 users click sumbit button at a
> time. we r getiing same value . so hoe to solve the problem

You need to use a sequence.

You can either have the database assign the value automatically by
declaring the field type to be serial (instead of int) or bigserial
(instead of int8) or you can assign the value yourself using the nextval
/ currval functions.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Broersma Jr 2006-04-10 21:29:02 Re: trigger firing order
Previous Message felix 2006-04-10 21:20:21 Re: Asking advice on speeding up a big table