Re: Proper state after insertRow - Mailing list pgsql-jdbc

From Paul Stead
Subject Re: Proper state after insertRow
Date
Msg-id BNENLMOEFCOIEGKDJMLLMEMGCBAA.pstead@elementallogic.com
Whole thread Raw
In response to Proper state after insertRow  (Dave Cramer <Dave@micro-automation.net>)
Responses Re: Proper state after insertRow  (Dave Cramer <Dave@micro-automation.net>)
List pgsql-jdbc
Dave,

No expert here, but according to JDBC API Tutorial and Reference, 2nd Ed,
from the Java Series:
(pg 596 - top) ".....the application calls the method insertRow.  This
method adds the insert row to both the result set and the underlying
database simultaneously.  Finally, the application neeeds to position the
cursor on a row back in the result set."

So I would think the cursor stays on the insert row, which is "a special
row, associated with the result set but *not a part of it*", and the
application must move the cursor where it wants from there.  As it says "the
application  needs to position the cursor on a row back in the result set".

and then

(pg 596 - bottom) "....a result set keeps track of where its cursor was
positioned when the cursor moved to the insert row.  As a result, a call to
the method ResultSet.moveToCurrentRow will return the cursor to the row that
was the current row immediately before the method moveToInsertRow was
called."

So IMHO while the cursor remains on the insert row, the inserted row itself
does *not* become the current row, since "the method
ResultSet.moveToCurrentRow will return the cursor to the row that was the
current row immediately before the method moveToInsertRow was called".

Once the application has moved the cursor back to the result set, I don't
think a refreshRow would be needed since insertRow "adds the insert row to
both the result set and underlying database simultaneously."

And finally, once the application has executed insertRow, I don't think they
can update that particular row without moving.  I think the insert row stays
a staging area and perhaps you could "stay there" (i.e. leave the cursor
there) and do some more updateInt updateString calls etc., but once you call
insertRow again it will insert yet another new row into the result set and
database providing you have updated all the necessary columns.  It would
seem that the insert row should be "cleared" when insertRow is called, so
that if someone didn't treat it like starting over they'd get an exception.
Otherwise it might be a little dangerous.

Anywho, that's how I read all this.....

Hope this helps!
Paul


-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of Dave Cramer
Sent: Friday, August 23, 2002 6:48 AM
To: Zengfa Gao
Cc: pgsql-jdbc@postgresql.org
Subject: [JDBC] Proper state after insertRow


Does anyone know what the state of the result set should be after an
insertRow

Does the result set stay on the "insertRow", does the inserted row
become the current row

should we force the user to do a refreshRow after an insert to pick up
the results of sequences, etc.

after the user executes insertRow, can they then update this row without
moving?

Dave


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org


pgsql-jdbc by date:

Previous
From: Jason Stewart
Date:
Subject: Authentication Problems
Next
From: Toby
Date:
Subject: Re: Tomcat and JDK 1.3.1 Exception problems...