Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

UPDATE

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am looking through the resultset and when I get a row of interest, then I want to update a few columns in the same row.
I am wondering whether I have to specify a 'where' clause in the update syntax, since I am looping through and the the row to be updated in the current row....
while( resultset.next() )
{
String status = resultset.getString("STATUS") ;
if( status == 12 )
{
String update = "update tablename set col1='1', col2='sd'";
stmt.executeUpdate(update);
}
}
Will the above 'update' statemet recognize that it has to update the current row?
Thanks!!
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think so!
How should it? The update statement is executed on the database and the database has no idea in which row of the resultSet you are. I think, the whole table will get the specified values in the columns!
 
Bala Krishniah
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Lars Vegas...
Then in hat case I'll specify the current row's Unique id no.
Thanks
 
Our first order of business must be this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic