Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id BBB799FB1DC for ; Thu, 1 Feb 2007 14:13:23 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 56882-07 for ; Thu, 1 Feb 2007 14:13:15 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id 3DBA99F9F0A for ; Thu, 1 Feb 2007 14:13:15 -0400 (AST) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1HCgc1-000158-6r for pgsql-sql@postgresql.org; Thu, 01 Feb 2007 13:24:45 -0500 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id CFE414172; Thu, 1 Feb 2007 13:13:05 -0500 (EST) Date: Thu, 1 Feb 2007 13:13:05 -0500 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: Insert Data and autonumeric field Message-ID: <20070201181305.GC7985@phlogiston.dyndns.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.9i Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/3 X-Sequence-Number: 27337 On Thu, Feb 01, 2007 at 04:09:22PM -0300, Andr=E9 Jos=E9 Guergolet wrote: > PROBLEM: Many clients are getting duplicated IDs. >=20 > 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 --=20 Andrew Sullivan | ajs@crankycanuck.ca Information security isn't a technological problem. It's an economics problem. --Bruce Schneier