deleteRow or updateRow after insertRow

Поиск
Список
Период
Сортировка
Искать

deleteRow or updateRow after insertRow

От:
"jessica xingzc_he" <xingzc_he@hotmail.com>
Дата:
does anyone know why this happen?

I do first:
ResultSet.moveToInsertRow();
ResultSet.update...(1, ...);
....
rs.insertRow(); // a new row inserted into table

but after that, I may move to some other row, say using Result.absolute(..) 
or so, and then
1. update
ResultSet.update...(1, ...);
...
ResultSet.updateRow(); // it does not update the corresponding row in the 
table, but also no
                                     exception thrown.

2. delete
ResultSet.deleteRow(); // throws exception: Can not call deleteRow() when on 
insert row.

anybody has any clue? thanks

zhenchang


Re: deleteRow or updateRow after insertRow

От:
Dave Cramer <pg@fastcrypt.com>
Дата:
You may need to tell us a little more like what version of the driver 
you are using ?

--dc--

jessica xingzc_he wrote:

> does anyone know why this happen?
>
> I do first:
> ResultSet.moveToInsertRow();
> ResultSet.update...(1, ...);
> ....
> rs.insertRow(); // a new row inserted into table
>
> but after that, I may move to some other row, say using 
> Result.absolute(..) or so, and then
> 1. update
> ResultSet.update...(1, ...);
> ...
> ResultSet.updateRow(); // it does not update the corresponding row in 
> the table, but also no
>                                     exception thrown.
>
> 2. delete
> ResultSet.deleteRow(); // throws exception: Can not call deleteRow() 
> when on insert row.
>
> anybody has any clue? thanks
>
> zhenchang
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
>      subscribe-nomail command to majordomo@postgresql.org so that your
>      message can get through to the mailing list cleanly
>
>

-- 
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561

Re: deleteRow or updateRow after insertRow

От:
"jessica xingzc_he" <xingzc_he@hotmail.com>
Дата:
The server is 7.4.5, and the jdbc driver is pg74.213.jdbc3.

thanks

>From: Dave Cramer 
>Reply-To: pg@fastcrypt.com
>To: jessica xingzc_he 
>CC: pgsql-jdbc@postgresql.org
>Subject: Re: [JDBC] deleteRow or updateRow after insertRow
>Date: Thu, 18 Nov 2004 18:26:44 -0500
>
>You may need to tell us a little more like what version of the driver you 
>are using ?
>
>--dc--
>
>jessica xingzc_he wrote:
>
>>does anyone know why this happen?
>>
>>I do first:
>>ResultSet.moveToInsertRow();
>>ResultSet.update...(1, ...);
>>....
>>rs.insertRow(); // a new row inserted into table
>>
>>but after that, I may move to some other row, say using 
>>Result.absolute(..) or so, and then
>>1. update
>>ResultSet.update...(1, ...);
>>...
>>ResultSet.updateRow(); // it does not update the corresponding row in the 
>>table, but also no
>>                                     exception thrown.
>>
>>2. delete
>>ResultSet.deleteRow(); // throws exception: Can not call deleteRow() when 
>>on insert row.
>>
>>anybody has any clue? thanks
>>
>>zhenchang
>>
>>
>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 3: if posting/reading through Usenet, please send an appropriate
>>      subscribe-nomail command to majordomo@postgresql.org so that your
>>      message can get through to the mailing list cleanly
>>
>>
>
>--
>Dave Cramer
>http://www.postgresintl.com
>519 939 0336
>ICQ#14675561
>


Re: deleteRow or updateRow after insertRow

От:
Oliver Jowett <oliver@opencloud.com>
Дата:
jessica xingzc_he wrote:

> I do first:
> ResultSet.moveToInsertRow();
> ResultSet.update...(1, ...);
> ....
> rs.insertRow(); // a new row inserted into table
> 
> but after that, I may move to some other row, say using 
> Result.absolute(..) or so, and then
> 1. update
> ResultSet.update...(1, ...);
> ...
> ResultSet.updateRow(); // it does not update the corresponding row in 
> the table, but also no
>                                     exception thrown.
> 
> 2. delete
> ResultSet.deleteRow(); // throws exception: Can not call deleteRow() 
> when on insert row.

Both cases sound like the driver thinks you are on the insert row. Are 
you sure that you are navigating away from the insert row after calling 
insertRow() and are not returning to it for some reason?

Does the problem still occur if you use the latest development driver? 
If so, do you have a testcase that demonstrates it?

It looks like updateRow when on the insert row is handle incorrectly :we 
should throw an exception according to the javadoc, but we silently do 
nothing. I will fix this in the development driver shortly. It won't 
help your problem, though..

-O

Re: deleteRow or updateRow after insertRow

От:
"jessica xingzc_he" <xingzc_he@hotmail.com>
Дата:
it seems that moveToCurrentRow(), first(), last(), etc. work after 
insertRow(). But using absolute() to navigate some row else does not.

>From: Oliver Jowett 
>To: jessica xingzc_he 
>CC: pgsql-jdbc@postgresql.org
>Subject: Re: [JDBC] deleteRow or updateRow after insertRow
>Date: Fri, 19 Nov 2004 15:14:51 +1300
>
>jessica xingzc_he wrote:
>
>>I do first:
>>ResultSet.moveToInsertRow();
>>ResultSet.update...(1, ...);
>>....
>>rs.insertRow(); // a new row inserted into table
>>
>>but after that, I may move to some other row, say using 
>>Result.absolute(..) or so, and then
>>1. update
>>ResultSet.update...(1, ...);
>>...
>>ResultSet.updateRow(); // it does not update the corresponding row in the 
>>table, but also no
>>                                     exception thrown.
>>
>>2. delete
>>ResultSet.deleteRow(); // throws exception: Can not call deleteRow() when 
>>on insert row.
>
>Both cases sound like the driver thinks you are on the insert row. Are you 
>sure that you are navigating away from the insert row after calling 
>insertRow() and are not returning to it for some reason?
>
>Does the problem still occur if you use the latest development driver? If 
>so, do you have a testcase that demonstrates it?
>
>It looks like updateRow when on the insert row is handle incorrectly :we 
>should throw an exception according to the javadoc, but we silently do 
>nothing. I will fix this in the development driver shortly. It won't help 
>your problem, though..
>
>-O


Re: deleteRow or updateRow after insertRow

От:
Kris Jurka <books@ejurka.com>
Дата:


On Thu, 18 Nov 2004, jessica xingzc_he wrote:

> it seems that moveToCurrentRow(), first(), last(), etc. work after 
> insertRow(). But using absolute() to navigate some row else does not.

This could be a problem solved by this fix, if absolute positions you off 
the ResultSet.

date: 2004/06/21 03:11:49;  author: jurka;  state: Exp;  lines: +15 -1
Fix some problems with result sets positioned before the start or
after the end of results.  You could still call a number of methods
on them like getXXX, updateXXX, and updateRow().

I don't recall the details, but you should try build 215 as well as the 
lastest build 308.  If either of these still give you problems, please 
send us a complete java class which we can run, not just snippets of code.

Kris Jurka
FAQ