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 F154152BD7 for ; Wed, 27 Jul 2005 11:15:53 -0300 (ADT) 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 63582-05 for ; Wed, 27 Jul 2005 14:15:43 +0000 (GMT) Received: from smtp.profdata.nl (server.profdata.nl [213.196.2.244]) by svr1.postgresql.org (Postfix) with SMTP id F096852871 for ; Wed, 27 Jul 2005 11:15:41 -0300 (ADT) Received: (qmail 2459 invoked from network); 27 Jul 2005 14:15:45 -0000 Received: from unknown (HELO ?10.0.0.3?) (62.221.227.121) by server.profdata.nl with SMTP; 27 Jul 2005 14:15:45 -0000 Message-ID: <42E79710.2050509@sebster.com> Date: Wed, 27 Jul 2005 16:15:44 +0200 From: Sebastiaan van Erk User-Agent: Mozilla Thunderbird 1.0.5 (X11/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: INSERT and get ID References: <3617A3C21370D045B75C0A40A7A6530D0B37E19A@ntexc2buc.do-office.buc.materna.com> <42E791BD.2030808@mosaic-ag.com> In-Reply-To: <42E791BD.2030808@mosaic-ag.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200507/364 X-Sequence-Number: 13512 If you're going to do an extra select anyway, I would do it *before* the insert. Select the nextval from the sequence and use that as the primary key for the insert. Greetings, Sebastiaan Roland Walter wrote: > Peter.Zoche@materna.de schrieb: > >>> You have to do a a "SELECT curval('myseq')" after the insert. >> >> >> >> I had this in mind, too, but I am not sure if it is really safe if >> there are several inserts at the same time... >> > > What do you mean with at the same time? > > Different connections see different sequence values. So there is no > need to worry. > > If you did the > insertions within the same connection, you have to ask the current value > of the sequence after each INSERT. > >