pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Sullivan <ajs@crankycanuck.ca>
To: pgsql-sql@postgresql.org
Subject: Re: Insert Data and autonumeric field
Date: Thu, 1 Feb 2007 13:13:05 -0500
Message-ID: <20070201181305.GC7985@phlogiston.dyndns.org> (raw)
In-Reply-To: <E426DDFE0FB5634AA3C997254DCBDE4EDF3C91@cgexc04.compugraf.com.br>
References: <E426DDFE0FB5634AA3C997254DCBDE4EDF3C91@cgexc04.compugraf.com.br>

On Thu, Feb 01, 2007 at 04:09:22PM -0300, André José Guergolet wrote:
> PROBLEM: Many clients are getting duplicated IDs.
> 
> What is the best way of doing this?

Use a sequence.  You can get the current value of the sequence with
SELECT currval('seqname').  No, there's not a race condition; see the
docs.

A

-- 
Andrew Sullivan  | ajs@crankycanuck.ca
Information security isn't a technological problem.  It's an economics
problem.
		--Bruce Schneier



view thread (3+ messages)  latest in thread

Message-ID: <20070201181305.GC7985@phlogiston.dyndns.org>
Permalink:  ../20070201181305.GC7985@phlogiston.dyndns.org/
Also on:    postgresql.org/message-id/20070201181305.GC7985@phlogiston.dyndns.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ajs@crankycanuck.ca
  Subject: Re: Insert Data and autonumeric field
  In-Reply-To: <20070201181305.GC7985@phlogiston.dyndns.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox