Обсуждение: DELETING ROW

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

DELETING ROW

От
Gabriel López Millán
Дата:
Hi all.
   I'm traying to delete a row of a table. Te code is:
String query = "DELETE FROM " + ID_REQUEST_TABLE + " WHERE id = '" +
numReq+ "';";int result = s.executeUpdate(query);System.out.println("result: " + result);if(result != 0) {    .....
connection.commit();}
 

   If file do not exists "result" should be "0" (JDBC API), if exists,
it should be the number of the row that delete. But I always get the
value "1", always, even if the row to delete is 5,6, ... 10.
   I'm using postgresql 7.02 with linux RedHat 6.0 and jdk1.2
   Cheers, Gabi.


Re: DELETING ROW

От
Bob Kline
Дата:
On Wed, 12 Jul 2000, Gabriel [iso-8859-1] L�pez Mill�n wrote:

> 
>     Hi all.
> 
>     I'm traying to delete a row of a table. Te code is:
> 
>  String query = "DELETE FROM " + ID_REQUEST_TABLE + " WHERE id = '" +
> numReq+ "';";
>  int result = s.executeUpdate(query);
>  System.out.println("result: " + result);
>  if(result != 0) {
>      .....
>      connection.commit();
>   }
> 
> 
>     If file do not exists "result" should be "0" (JDBC API), if exists,
> it should be the number of the row that delete. But I always get the
> value "1", always, even if the row to delete is 5,6, ... 10.
> 
>     I'm using postgresql 7.02 with linux RedHat 6.0 and jdk1.2
> 
>     Cheers, Gabi.
> 

If you read the docs a little more carefully, I think you'll find that
the return value is the number of rows affected by the statement.

-- 
Bob Kline
mailto:bkline@rksystems.com
http://www.rksystems.com



Re: DELETING ROW

От
Gabriel López Millán
Дата:
Bob Kline wrote:

> On Wed, 12 Jul 2000, Gabriel [iso-8859-1] López Millán wrote:
>
> >
> >     Hi all.
> >
> >     I'm traying to delete a row of a table. Te code is:
> >
> >  String query = "DELETE FROM " + ID_REQUEST_TABLE + " WHERE id = '" +
> > numReq+ "';";
> >  int result = s.executeUpdate(query);
> >  System.out.println("result: " + result);
> >  if(result != 0) {
> >      .....
> >      connection.commit();
> >   }
> >
> >
> >     If file do not exists "result" should be "0" (JDBC API), if exists,
> > it should be the number of the row that delete. But I always get the
> > value "1", always, even if the row to delete is 5,6, ... 10.
> >
> >     I'm using postgresql 7.02 with linux RedHat 6.0 and jdk1.2
> >
> >     Cheers, Gabi.
> >
>
> If you read the docs a little more carefully, I think you'll find that
> the return value is the number of rows affected by the statement.
       OK.
       And if I try to delete a row that do not exits, the result is the
same '1'. ¿It is also correct?



Re: DELETING ROW

От
Bob Kline
Дата:
On Thu, 13 Jul 2000, Gabriel [iso-8859-1] L�pez Mill�n wrote:

> Bob Kline wrote:
> 
> > On Wed, 12 Jul 2000, Gabriel [iso-8859-1] L�pez Mill�n wrote:
> >
> > >
> > >     Hi all.
> > >
> > >     I'm traying to delete a row of a table. Te code is:
> > >
> > >  String query = "DELETE FROM " + ID_REQUEST_TABLE + " WHERE id = '" +
> > > numReq+ "';";
> > >  int result = s.executeUpdate(query);
> > >  System.out.println("result: " + result);
> > >  if(result != 0) {
> > >      .....
> > >      connection.commit();
> > >   }
> > >
> > >
> > >     If file do not exists "result" should be "0" (JDBC API), if exists,
> > > it should be the number of the row that delete. But I always get the
> > > value "1", always, even if the row to delete is 5,6, ... 10.
> > >
> > >     I'm using postgresql 7.02 with linux RedHat 6.0 and jdk1.2
> > >
> > >     Cheers, Gabi.
> > >
> >
> > If you read the docs a little more carefully, I think you'll find that
> > the return value is the number of rows affected by the statement.
> 
>         OK.
> 
>         And if I try to delete a row that do not exits, the result is the
> same '1'. �It is also correct?
> 

Nope.  That would be a bug in the driver.

-- 
Bob Kline
mailto:bkline@rksystems.com
http://www.rksystems.com