Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9C8B4475C2A; Mon, 2 Sep 2002 15:50:33 -0400 (EDT) Received: from primus.vsservices.com (unknown [63.66.136.75]) by postgresql.org (Postfix) with ESMTP id E7678475B88; Mon, 2 Sep 2002 15:50:32 -0400 (EDT) Received: from prime.vsservices.com (conr-adsl-dhcp-26-247.txucom.net [209.34.26.247]) by primus.vsservices.com (8.12.5/8.12.5) with SMTP id g82JoWMX052246; Mon, 2 Sep 2002 14:50:33 -0500 (CDT) (envelope-from postgres@vsservices.com) Date: Mon, 2 Sep 2002 14:50:33 -0500 From: GB Clark To: friedrich nietzsche Cc: pgsql-sql@postgresql.org, pgsql-general@postgresql.org Subject: Re: [SQL] Retrieving the new "nextval" for primary keys.... Message-Id: <20020902145033.4a621385.postgres@vsservices.com> In-Reply-To: <20020828163610.70353.qmail@web12907.mail.yahoo.com> References: <3D6CF5B7.90206@nurseamerica.net> <20020828163610.70353.qmail@web12907.mail.yahoo.com> X-Mailer: Sylpheed version 0.8.2 (GTK+ 1.2.10; i386-portbld-freebsd4.6) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/23 X-Sequence-Number: 29604 On Wed, 28 Aug 2002 18:36:10 +0200 (CEST) friedrich nietzsche wrote: > One solution seems to locking table(s), > but I prefer to leave it as last chance... > using table locks, and the trick of writing and > suddenly reading back from DB it probably works, > but it doesn't seems so sexy... :) > ciao > danilo > Why would you have to lock the table? currval() is connection safe. I would either do the insert and then do a currval() OR do a nextval() and do the insert. Either one would work. I always just do the insert and then call currval() to get the current serial number for the connection. GB -- GB Clark II | Roaming FreeBSD Admin gclarkii@VSServices.COM | General Geek CTHULU for President - Why choose the lesser of two evils?