• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is there any function like saveOrUpdate

 
Fawad Ali
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I just wanted to know if there is any function in JDBC which could do saveOrUpdate based on the existence of a primary key i.e if a primary key for the object to be inserted exists in db then it should update that record otherwise insert the record.
 
Sam Falzon
Greenhorn
Posts: 5
Linux
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What database and which version are you using? If you are using Oracle, look into the MERGE comand.
 
Fawad Ali
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using mySql server...
 
Paul Clapham
Sheriff
Pie
Posts: 20203
26
MySQL Database
  • 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I googled for "mysql update or insert". From that I found that many people had asked that question on the MySQL forum, and Google kindly provided me with links to those questions. I just chose the first link, and noticed that the first answer on that forum was this:

http://dev.mysql.com/doc/refman/5.0/en/replace.html

In other words, the answer to your question is... Yes.
 
Fawad Ali
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul. It helped.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic