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

Re: getXXX throws SQLException while on insert row

From: Kris Jurka <books(at)ejurka(dot)com>
To: Prasanth Reddy <dbadmin(at)nqadmin(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: getXXX throws SQLException while on insert row
Date: 2007-12-01 09:42:40
Message-ID: (view raw, whole thread or download thread mbox)
Lists: 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 

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 

Kris Jurka

In response to


pgsql-jdbc by date

Next:From: Dave CramerDate: 2007-12-01 12:35:38
Subject: Re: prepared statement using postgres array
Previous:From: Kris JurkaDate: 2007-12-01 09:19:17
Subject: Re: "create type" custom types not supported by JDBC

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