Re: getting primary key values for inserted records? - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: getting primary key values for inserted records?
Date
Msg-id Pine.LNX.4.33.0401271219200.27584-100000@leary.csoft.net
Whole thread Raw
In response to getting primary key values for inserted records?  (Guido Fiala <guido.fiala@dka-gmbh.de>)
List pgsql-jdbc

On Tue, 27 Jan 2004, Guido Fiala wrote:

> Hallo,
>
> I'am currently at the point, that after i insert a new Record in a ResultSet
> using insertRow() and using a serial for the primary key of the target table.
>
> Of course i do not call rs.updateInt(primaryKey), as the sequence does get me
> the new value automatically.
>
> However - even using rs.refreshRow() doesn't get me the values, just a requery
> of the ResultSet.
>
> What is the way to go here?
>

Other than reissuing the query, the only real way around this is to
separately issue a nextval call on the sequence and use that value in
rs.updateInt.  There is no way for the JDBC driver to know what the
primary key turned out to be otherwise.

Kris Jurka




pgsql-jdbc by date:

Previous
From: Barry Lind
Date:
Subject: Re: Patch to readd documentation
Next
From: Jeremy Buchmann
Date:
Subject: Re: getting primary key values for inserted records?