From: Kris Jurka <books@ejurka.com>
To: Prasanth Reddy <dbadmin@nqadmin.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: getXXX throws SQLException while on insert row
Date: Sat, 1 Dec 2007 04:42:40 -0500 (EST)
Message-ID: <Pine.BSO.4.64.0712010435440.12362@leary.csoft.net> (raw)
In-Reply-To: <4726383A.8060909@nqadmin.com>
References: <4726383A.8060909@nqadmin.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: books@ejurka.com, dbadmin@nqadmin.com
Subject: Re: getXXX throws SQLException while on insert row
In-Reply-To: <Pine.BSO.4.64.0712010435440.12362@leary.csoft.net>
References: <4726383A.8060909@nqadmin.com> <Pine.BSO.4.64.0712010435440.12362@leary.csoft.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox