Re: getXXX throws SQLException while on insert row - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: getXXX throws SQLException while on insert row
Date
Msg-id Pine.BSO.4.64.0712010435440.12362@leary.csoft.net
Whole thread Raw
In response to getXXX throws SQLException while on insert row  (Prasanth Reddy <dbadmin@nqadmin.com>)
Responses Re: getXXX throws SQLException while on insert row  (andreasfreyer <freyer@online.de>)
List pgsql-jdbc

On Mon, 29 Oct 2007, Prasanth Reddy wrote:

> Should the below code throw an SQLException?
>
> rs.moveToInsertRow();
> rs.updateInt("account_id", 1023);
> rs.getInt("account_id");      - shouldn't this return 1023 rather than
> throwing SQLException?
>
> Below is the exception:
> org.postgresql.util.PSQLException: ResultSet not positioned properly,
> perhaps you need to call next.

It's not clear.  Reading the JDBC spec it doesn't seem to say anything
about fetching data from a partially updated ResultSet.  Also note that
this doesn't work as you might expect for an update of a regular ResultSet
row.

int i = rs.getInt(1);
rs.updateInt(1, i+1);
// here j will be == i, not i+1.
int j = rs.getInt(1);

We store the pending values in a separate area because it makes things
like cancelRowUpdates or just navigating away from the updated row without
issuing updateRow easy.  While I can see the utility of being able to
fetch the updated values, it would complicate the driver, so I'm not
excited about it unless you can point to some documentation that says we
should.

Kris Jurka

pgsql-jdbc by date:

Previous
From: Kris Jurka
Date:
Subject: Re: "create type" custom types not supported by JDBC
Next
From: Dave Cramer
Date:
Subject: Re: prepared statement using postgres array