Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 50ADE9FC108 for ; Thu, 18 Oct 2007 16:56:22 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 64600-03-3 for ; Thu, 18 Oct 2007 16:56:13 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from davinci.ethosmedia.com (server227.ethosmedia.com [209.128.84.227]) by postgresql.org (Postfix) with ESMTP id 2B3A69FC35F for ; Thu, 18 Oct 2007 16:56:15 -0300 (ADT) X-EthosMedia-Virus-Scanned: no infections found Received: from [63.195.55.98] (account josh@agliodbs.com HELO [192.168.2.3]) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 13594270; Thu, 18 Oct 2007 13:00:44 -0700 From: Josh Berkus Organization: PostgreSQL @ Sun To: pgsql-jdbc@postgresql.org Subject: Re: Fw: postgresql experts please help Date: Thu, 18 Oct 2007 12:57:37 -0700 User-Agent: KMail/1.8.2 Cc: Kris Jurka , Andrei Ilitchev , Marina Vatkina References: <001101c81189$2f3f52d0$4c349c0a@ca.oracle.com> <00d601c811b7$47c1a6e0$4c349c0a@ca.oracle.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200710181257.37449.josh@agliodbs.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/105 X-Sequence-Number: 17677 Kris, > If you have an after trigger on the table that you're inserting into and > it inserts into another table with a serial column, the lastval call will > use the wrong sequence. Now this is also a problem with currval if you > have a trigger that inserts into the same table, but that's an unlikely > application design. Inserting into another table is something that you'll > find with systems that do auditing or sometimes horizontal partitioning of > a table. I'm pretty sure there's a version of lastval() which takes the table name as a parameter. That would be the safer one to use. -- Josh Berkus PostgreSQL @ Sun San Francisco