Received: from smtp03.mail.gol.com (smtp03.mail.gol.com [203.216.5.13]) by hub.org (8.9.3/8.9.3) with ESMTP id HAA42214 for ; Wed, 19 Apr 2000 07:38:47 -0400 (EDT) (envelope-from rmager@vgkk.co.jp) Received: from wks02 (tc-2-052.ariake.gol.ne.jp [203.216.43.52]) by smtp03.mail.gol.com (Postfix) with SMTP id B33CA404D for ; Wed, 19 Apr 2000 20:35:46 +0900 (JST) From: "Rainer Mager" To: Subject: RE: Date: Wed, 19 Apr 2000 20:41:58 +0900 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal In-Reply-To: <38FD7D97.A683EE35@eurocom.od.ua> X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 X-Archive-Number: 200004/73 Does anyone know of a good way to do something similar in Java (JDBC) connected to Postgres? Thanks, --Rainer > -----Original Message----- > From: pgsql-admin-owner@hub.org > [mailto:pgsql-admin-owner@hub.org]On Behalf Of Vladimir V. Zolotych > Sent: Wednesday, April 19, 2000 6:34 PM > To: Andrew Perrin - Demography > Cc: pgsql-admin@postgresql.org > Subject: [ADMIN] > > > > ......... In my case, I used currval(). Basically: > > > > SELECT currval('table_field_seq'); > > > > will return the most recently assigned value to the field *by the > > current > > backend* which means: > > > > - There's no danger of a race condition (another user creating a > > record in > > the time between your creating the record and calling currval); BUT > > - You must be using the same backend as you did on the creation. > > This is the way I've used before. It seems the the better way > (thanks to Charles Martin ) is: > > 1) Do INSERT > PGresult* res = PQexec(conn, "INSERT......") > > 2) Get the OID of the just inserted record e.g > const char* oid = PQoidStatus(res) > > 3) Select the id of this record: > res = PQexec(conn, "SELECT id .... WHERE OID=...."); > > >