Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 812939FB318 for ; Mon, 5 Mar 2007 19:09:43 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 12275-06 for ; Mon, 5 Mar 2007 19:09:38 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mx1.progress.com (mx1.progress.com [192.77.186.16]) by postgresql.org (Postfix) with ESMTP id 517589FB205 for ; Mon, 5 Mar 2007 19:09:37 -0400 (AST) Received: from mx1.progress.com (127.0.0.1) by mx1.progress.com (MlfMTA v3.2r1b3) id htihj00171s7 for ; Mon, 5 Mar 2007 18:09:36 -0500 (envelope-from ) Received: from progress.com ([192.233.92.16]) by mx1.progress.com (SonicWALL 5.0.2.8415) with ESMTP; Mon, 05 Mar 2007 18:09:36 -0500 Received: from NTEXFE01.bedford.progress.com (ntexfe01 [172.16.2.61]) by progress.com (8.13.8/8.13.8) with ESMTP id l25N9Zpr020792; Mon, 5 Mar 2007 18:09:35 -0500 (EST) Received: from MAIL03.bedford.progress.com ([172.16.2.59]) by NTEXFE01.bedford.progress.com with Microsoft SMTPSVC(6.0.3790.1830); Mon, 5 Mar 2007 18:09:35 -0500 x-mimeole: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: Fetching generated keys Date: Mon, 5 Mar 2007 18:09:32 -0500 Message-ID: <626C0646ACE5D544BC9675C1FB81846B3388DC@MAIL03.bedford.progress.com> In-Reply-To: <1173133716.16656.1017.camel@archimedes> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [JDBC] Fetching generated keys Thread-Index: AcdfdaAMt0VbDaywQCmIlReIyOOQlgABZSeA From: "Mike Clements" To: "Mark Lewis" Cc: "PostgreSQL JDBC List" X-OriginalArrivalTime: 05 Mar 2007 23:09:35.0886 (UTC) FILETIME=[579CD2E0:01C75F7B] X-Mlf-Version: 5.0.2.8415 X-Mlf-UniqueId: o200703052309360043110 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/49 X-Sequence-Number: 16763 Thanks everyone for the quick help and explanations. -----Original Message----- From: Mark Lewis [mailto:mark.lewis@mir3.com]=20 Sent: Monday, March 05, 2007 5:29 PM To: Mike Clements Cc: A.M.; PostgreSQL JDBC List Subject: Re: [JDBC] Fetching generated keys On Mon, 2007-03-05 at 17:19 -0500, Mike Clements wrote: ... > The FAQ you posted suggests that "currval" uses a level of isolation=20 > that is more strict than the default "read committed". If so, setting=20 > isolation level to serializable would be unnecessary. Is that true? Or > should I do it just to be safe? I'd hate to do it if unnecessary due=20 > to the performance and locking implications. Yes, currval definitely returns the last value returned by the sequence in the current transaction. Anything done in other transactions is ignored. Just for kicks, I did a simple test with two psql sessions to demonstrate: psql1: BEGIN TRANSACTION; psql1: SELECT nextval('my_seq'); -- returns 4988 psql2: BEGIN TRANSACTION; psql2: SELECT nextval('my_seq'); -- returns 4989 psql1: SELECT currval('my_seq'); -- returns 4988 (also tested with psql2 committing the transaction before psql1 reads currval. Made no difference.) -- Mark Lewis