X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DA626545F4 for ; Mon, 21 Mar 2005 12:37:49 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 72664-04 for ; Mon, 21 Mar 2005 12:37:49 +0000 (GMT) Received: from mnc.ch (unknown [212.23.250.43]) by svr1.postgresql.org (Postfix) with ESMTP id 83A34545A2 for ; Mon, 21 Mar 2005 12:37:46 +0000 (GMT) Received: (qmail 11527 invoked from network); 21 Mar 2005 13:37:48 +0100 Received: from 62-2-77-204.business.cablecom.ch (HELO meuh.mnc.ch) (62.2.77.204) by www.mnc.ch.com with SMTP; 21 Mar 2005 13:37:48 +0100 Received: by meuh.mnc.ch (Postfix, from userid 1000) id D557523F50C; Mon, 21 Mar 2005 13:37:44 +0100 (CET) To: pg@fastcrypt.com Cc: Nico , pgsql-jdbc@postgresql.org Subject: Re: getting a sequence value References: <423EBDFA.9040507@fastcrypt.com> From: Guillaume Cottenceau Date: 21 Mar 2005 13:37:44 +0100 In-Reply-To: <423EBDFA.9040507@fastcrypt.com> Message-ID: <87acoxuqcn.fsf@meuh.mnc.ch> Lines: 15 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.052 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200503/171 X-Sequence-Number: 12563 Dave Cramer writes: > 2) > allow the insert to go through > select currval('public."tblTable1_FieldID_seq"'::text) > and then use this to insert into table 2 > > FYI currval does the "right" thing. It is guaranteed to be the value > your connection retrieved from the sequence. Which can be wrong in case of multithreaded applications without synchronization over the two requests, if I'm correct. -- Guillaume Cottenceau