• 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
Sheriff
Posts: 36032
432
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.
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!