pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrei Ilitchev <andrei.ilitchev@oracle.com>
To: Kris Jurka <books@ejurka.com>
Cc: pgsql-jdbc@postgresql.org
Cc: Marina Vatkina <Marina.Vatkina@Sun.COM>
Subject: Re: Fw: postgresql experts please help
Date: Thu, 18 Oct 2007 14:47:05 -0400
Message-ID: <00d601c811b7$47c1a6e0$4c349c0a@ca.oracle.com> (raw)
References: <001101c81189$2f3f52d0$4c349c0a@ca.oracle.com>
	<Pine.BSO.4.64.0710181343220.25640@leary.csoft.net>

> 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" <books@ejurka.com>
To: "Andrei Ilitchev" <andrei.ilitchev@oracle.com>
Cc: <pgsql-jdbc@postgresql.org>; "Marina Vatkina" <Marina.Vatkina@Sun.COM>
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
> 




view thread (19+ messages)  latest in thread

Message-ID: <00d601c811b7$47c1a6e0$4c349c0a@ca.oracle.com>
Permalink:  ../00d601c811b7$47c1a6e0$4c349c0a@ca.oracle.com/
Also on:    postgresql.org/message-id/00d601c811b7$47c1a6e0$4c349c0a@ca.oracle.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: andrei.ilitchev@oracle.com, books@ejurka.com, Marina.Vatkina@Sun.COM
  Subject: Re: Fw: postgresql experts please help
  In-Reply-To: <00d601c811b7$47c1a6e0$4c349c0a@ca.oracle.com>
  References: <001101c81189$2f3f52d0$4c349c0a@ca.oracle.com> <Pine.BSO.4.64.0710181343220.25640@leary.csoft.net> <00d601c811b7$47c1a6e0$4c349c0a@ca.oracle.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox