Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id AA09F9FC294 for ; Thu, 18 Oct 2007 15:48:34 -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 07687-06 for ; Thu, 18 Oct 2007 15:48:27 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from agminet01.oracle.com (agminet01.oracle.com [141.146.126.228]) by postgresql.org (Postfix) with ESMTP id C6B0F9FC30F for ; Thu, 18 Oct 2007 15:48:28 -0300 (ADT) Received: from rgmgw2.us.oracle.com (rgmgw2.us.oracle.com [138.1.186.111]) by agminet01.oracle.com (Switch-3.2.4/Switch-3.1.7) with ESMTP id l9IImNCS028423; Thu, 18 Oct 2007 13:48:23 -0500 Received: from acsmt350.oracle.com (acsmt350.oracle.com [141.146.40.150]) by rgmgw2.us.oracle.com (Switch-3.2.4/Switch-3.2.4) with ESMTP id l9I3LjfH013087; Thu, 18 Oct 2007 12:48:22 -0600 Received: from ailitche-pc.ca.oracle.com by acsmt350.oracle.com with ESMTP id 3302976491192733196; Thu, 18 Oct 2007 11:46:36 -0700 Message-ID: <00d601c811b7$47c1a6e0$4c349c0a@ca.oracle.com> From: "Andrei Ilitchev" To: "Kris Jurka" Cc: , "Marina Vatkina" References: <001101c81189$2f3f52d0$4c349c0a@ca.oracle.com> Subject: Re: Fw: postgresql experts please help Date: Thu, 18 Oct 2007 14:47:05 -0400 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.3138 X-Mimeole: Produced By Microsoft MimeOLE V6.00.2900.3198 X-Brightmail-Tracker: AAAAAQAAAAI= X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE X-Whitelist: TRUE X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/103 X-Sequence-Number: 17675 > Any chance you have two man_id_seq sequences in different schemas? The > table insert might use one and the direct currval/nextval calls might use > another? I don't know how that happened but I think that's right: select of the row after insert returned ID=2, but somehow subsequent call to sequence's nextval returned 216. In the docs I discovered "select lastval()" which seems to behave exactly like @@Identity in Sybase returning the latest nextval that was obtained in the current session by no-matter-which sequence. That's exactly the functionality I need - much easier to use because no need to track the name. Can you think of any reason why using "select lastval()" would be a bad idea? Thanks a lot, Andrei ----- Original Message ----- From: "Kris Jurka" To: "Andrei Ilitchev" Cc: ; "Marina Vatkina" Sent: Thursday, October 18, 2007 1:45 PM Subject: Re: [JDBC] Fw: postgresql experts please help > > > On Thu, 18 Oct 2007, Andrei Ilitchev wrote: > >> 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. >> > > Any chance you have two man_id_seq sequences in different schemas? The > table insert might use one and the direct currval/nextval calls might use > another? > > Kris Jurka >