• 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

assigning result of executeQuery() to a variable??

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Considert the following situation:

I have a table 'table1'. now I first need to delete all data in 'table1' and then insert new data into it from another table, 'table2'.
Now if there is no data at all in table1, the next step (ie deletion) should not occur. For this I have written the code like this:




Is the above coding correct??

Thanks in advance.

[edited to add line breaks]
[ December 26, 2005: Message edited by: Jeanne Boyarsky ]
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your compiler will answer that. No. The executeQuery() method returns a ResultSet. You can't compare a ResultSet to an int.

But it's wasted effort anyway. Deleting everything from a table that contains zero rows isn't an error, and it does what you want: after it's done, the table contains zero rows. So don't bother trying to find if the table is empty or not, just delete all the rows if you want to empty the table.
 
Yell Srik
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks for the reply.
 
If you are using a rototiller, you are doing it wrong. Even on this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic