Received: from trends.net (root@clio.trends.ca [209.47.148.2]) by hub.org (8.9.3/8.9.3) with ESMTP id XAA01583 for ; Tue, 7 Dec 1999 23:55:40 -0500 (EST) (envelope-from dougt@mugc.cc.monash.edu.au) Received: from mugca.cc.monash.edu.au (dougt@mugca.cc.monash.edu.au [130.194.208.7]) by trends.net (8.8.8/8.8.8) with ESMTP id XAA10271 for ; Tue, 7 Dec 1999 23:37:36 -0500 (EST) Received: (from dougt@localhost) by mugca.cc.monash.edu.au (8.9.3/8.9.3) id PAA31285; Wed, 8 Dec 1999 15:34:33 +1100 (EST) Message-Id: <199912080434.PAA31285@mugca.cc.monash.edu.au> Subject: Re: [INTERFACES] locking on database updates To: gary.stainburn@ringways.co.uk (Gary Stainburn) Date: Wed, 8 Dec 1999 15:34:33 +1100 (EST) Cc: pgsql-interfaces@postgreSQL.org In-Reply-To: <01BF40D0.F4BA79A0@garys.ringways.co.uk> from "Gary Stainburn" at Dec 7, 99 04:34:37 pm Reply-To: dougt@mugc.cc.monash.edu.au From: Douglas Thomson X-Mailer: ELM [version 2.4 PL25] Content-Type: text Gary Stainburn writes: > 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? For what it is worth, I saved the OID returned by the INSERT (see PQoidStatus - the details depend on what interface language you use), and then selected the row I had just inserted using: SELECT id FROM name_map WHERE oid=12345 Doug.