• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Affected rows ?

 
Miran Cvenkel
Ranch Hand
Posts: 202
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sample



does this allways works ? Reeding around it is not always OK.

What if I would run: INSERT IGNORE ? Would it return 0 if nothing would be inserted ?

Is it affected by using prepared statement or not using it ?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually executeUpdate() returns the number of rows. It depends on your database/driver. So try it. It won't randomly not work later. It is not affected by PreparedStatement vs Statement.

I haven't heard of INSERT IGNORE. Google implies it is mySQL specific. Same advice - try it and see what happens. And post here so we can all learn .
 
Miran Cvenkel
Ranch Hand
Posts: 202
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
INSERT IGNORE is great, might be specific but is great.

You set unique key to field/fields and then insert ignore does not insert anything ower existing data.
Forinstance , if human names would be unique and you would not want to have many of 'john doe' in table.
Inserting 'ignore' him, from another source would have no effect.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic