Received: from wallace.ece.rice.edu (root@wallace.ece.rice.edu [128.42.12.154]) by hub.org (8.9.3/8.9.3) with ESMTP id MAA65786 for ; Tue, 7 Dec 1999 12:12:38 -0500 (EST) (envelope-from reedstrm@wallace.ece.rice.edu) Received: by wallace.ece.rice.edu via sendmail from stdin id (Debian Smail3.2.0.102) for pgsql-interfaces@postgresql.org; Tue, 7 Dec 1999 11:12:34 -0600 (CST) Date: Tue, 7 Dec 1999 11:12:34 -0600 From: "Ross J. Reedstrom" To: Gary Stainburn Cc: "'Pgsql Interfaces'" Subject: Re: [INTERFACES] locking on database updates Message-ID: <19991207111234.A6021@rice.edu> References: <01BF40D0.F4BA79A0@garys.ringways.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii User-Agent: Mutt/1.0i In-Reply-To: <01BF40D0.F4BA79A0@garys.ringways.co.uk>; from gary.stainburn@ringways.co.uk on Tue, Dec 07, 1999 at 04:34:37PM -0000 On Tue, Dec 07, 1999 at 04:34:37PM -0000, Gary Stainburn wrote: > Hi all, > > I've just read the last message I sent and apologise for the poor English. > Let me put it a little clearer. > > I agree that using a type 'serial' will give me what I want > regarding the key field for my table, and gets round the problem > of concurrent users trying to create records with the same number. > > The problem is that this does not actually give me the number that > was just created. As there is no guarantee that the other fields in > the table are unique (hence the serial field in the first place) I cannot > simply do a select to retrieve it. > > Has anyone any ideas? create table foo (bar serial, baz text); insert into foo (baz) values ('wooble'); select currval('foo_bar_seq'); > > Thanks, > > Gary you're welcome ;-) Ross -- Ross J. Reedstrom, Ph.D., NSBRI Research Scientist/Programmer Computer and Information Technology Institute Rice University, 6100 S. Main St., Houston, TX 77005