• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

assigning result of executeQuery() to a variable??

 
Yell Srik
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • 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 ]
 
Paul Clapham
Sheriff
Posts: 21559
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Hi,
Thanks for the reply.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic