Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 808079FC14C for ; Thu, 18 Oct 2007 14:34:46 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 57043-01-8 for ; Thu, 18 Oct 2007 14:34:43 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mir3-fs.mir3.com (mail.mir3.com [72.11.241.14]) by postgresql.org (Postfix) with ESMTP id 4E0149FC22D for ; Thu, 18 Oct 2007 14:34:30 -0300 (ADT) Received: MIR3-FS.mir3.com 172.16.1.11 from 172.16.2.68 172.16.2.68 via HTTP with MS-WebStorage 6.0.6249 Received: from archimedes by MIR3-FS.mir3.com; 18 Oct 2007 10:34:17 -0700 Subject: Re: Fw: postgresql experts please help From: Mark Lewis To: Andrei Ilitchev Cc: pgsql-jdbc@postgresql.org, Marina Vatkina In-Reply-To: <001101c81189$2f3f52d0$4c349c0a@ca.oracle.com> References: <001101c81189$2f3f52d0$4c349c0a@ca.oracle.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: MIR3, Inc. Date: Thu, 18 Oct 2007 10:34:17 -0700 Message-Id: <1192728857.6447.82.camel@archimedes> Mime-Version: 1.0 X-Mailer: Evolution 2.8.1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/96 X-Sequence-Number: 17668 On Thu, 2007-10-18 at 09:17 -0400, Andrei Ilitchev wrote: > Dear PostgreSQL jdbc experts, > > I created a table with identity: > CREATE TABLE MAN (ID SERIAL, NAME VARCHAR(40), PRIMARY KEY (ID)) > then through jdbc connection inserted a row into the table, > then attempted to select pk value back through the same jdbc connection > using currval - that failed with "not yet defined in this session" > exception. > > What's wrong here? You haven't disabled JDBC autocommit for this connection. That means that each statement gets executed in a separate transaction. Since currval is only valid within the scope of a single transaction, and you're executing your "select currval" from a separate transaction, that's why you can't see it. -- Mark Lewis