• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Insert or Update using prepared statement in java

 
seena mathew
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am a newbee in Java.
What I want to do in my program is to
1) insert a new row in case the row doesn't exist OR
2) Update the row if the row exists

I checked the api and didn't find anything
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pseudocode:

Unless of course your database has an "UPDATE-IF-ROW-EXISTS-ELSE-INSERT" command in its version of SQL. (Most of them don't.) But this would be a question about your database, rather than about JDBC.
 
Sudheer Bhat
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using Oracle as your DB, you can use MERGE statement.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic