aspose file tools*
The moose likes JDBC and the fly likes Insert or Update using prepared statement in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Insert or Update using prepared statement in java" Watch "Insert or Update using prepared statement in java" New topic
Author

Insert or Update using prepared statement in java

seena mathew
Greenhorn

Joined: Jun 14, 2009
Posts: 20
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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Feb 22, 2011
Posts: 75
If you are using Oracle as your DB, you can use MERGE statement.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Insert or Update using prepared statement in java