Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 749992E00DC for ; Sat, 1 Dec 2007 05:42:46 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 31547-05 for ; Sat, 1 Dec 2007 05:42:38 -0400 (AST) Received: from mail63.csoft.net (leary.csoft.net [205.205.214.5]) by postgresql.org (Postfix) with SMTP id 90F0F2E0094 for ; Sat, 1 Dec 2007 05:42:41 -0400 (AST) Received: (qmail 24930 invoked by uid 1112); 1 Dec 2007 09:42:40 -0000 Date: Sat, 1 Dec 2007 04:42:40 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Prasanth Reddy cc: pgsql-jdbc@postgresql.org Subject: Re: getXXX throws SQLException while on insert row In-Reply-To: <4726383A.8060909@nqadmin.com> Message-ID: References: <4726383A.8060909@nqadmin.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/5 X-Sequence-Number: 17860 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