Skip site navigation (1) Skip section navigation (2)

Re: Fw: postgresql experts please help

From: Michael Schmidt <MichaelMSchmidt(at)msn(dot)com>
To: Mark Lewis <mark(dot)lewis(at)mir3(dot)com>
Cc: Andrei Ilitchev <andrei(dot)ilitchev(at)oracle(dot)com>, pgsql-jdbc(at)postgresql(dot)org, Marina Vatkina <Marina(dot)Vatkina(at)Sun(dot)COM>
Subject: Re: Fw: postgresql experts please help
Date: 2007-10-18 17:58:28
Message-ID: BAYC1-PASMTP1354B178A3644A03954E90A39E0@CEZ.ICE (view raw or flat)
Thread:
Lists: pgsql-jdbc
Mark Lewis wrote:
> 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
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 7: You can help support the PostgreSQL project by donating at
> 
>                 http://www.postgresql.org/about/donate
> 
Also, from my read of the documentation and experience, you have to call 
nextval before you can call currval in the transaction.

Michael Schmidt

In response to

Responses

pgsql-jdbc by date

Next:From: Kris JurkaDate: 2007-10-18 18:03:23
Subject: Re: Fw: postgresql experts please help
Previous:From: Kris JurkaDate: 2007-10-18 17:45:58
Subject: Re: Fw: postgresql experts please help

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group