Re: Fw: postgresql experts please help

From: Mark Lewis <mark(dot)lewis(at)mir3(dot)com>
To: Andrei Ilitchev <andrei(dot)ilitchev(at)oracle(dot)com>
Cc: 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:34:17
Message-ID: 1192728857.6447.82.camel@archimedes
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

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

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2007-10-18 17:41:43 Re: Fw: postgresql experts please help
Previous Message Michael Paesold 2007-10-18 16:31:47 Re: Unable to prepare a statement when the object names contain more than one $ symbol