aspose file tools
The moose likes Oracle/OAS and the fly likes Regarding duplicate insert problem Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Products » Oracle/OAS
Reply Bookmark "Regarding duplicate insert problem" Watch "Regarding duplicate insert problem" New topic
Author

Regarding duplicate insert problem

vijay jamadade
Ranch Hand

Joined: May 12, 2008
Posts: 224
Hi Ranchers,

I am inserting the csv data through java in oracle.I want to check the whether the data I am inserting already exists in
table or not in insert query itself. Can I do that.

Because checking through select query before inserting the data is making the application heavy.

thanks in advance.


Regards, Vijay Jamadade.
( Nothing is Impossible.)
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26499
    
  78

Vijay,
There are two approaches:
1) Do a select first
2) Insert it anyway and fail on duplicate constraint

Which one you choose depends on the likelyhood of a duplicate occurring.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
vijay jamadade
Ranch Hand

Joined: May 12, 2008
Posts: 224
Insert any way does not work here because when exception occurs while inserting records one by one the code goes out of loop afterwards in java. And select first I think making the application heavy as for every insert it needs to be fire a query. How to handle that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding duplicate insert problem
 
Similar Threads
Passing cent symbol from jsp to servlet -- Problem
ant targets use to execute sql queries
difficulty in inserting value into oracle "long" datatype column
SQL Exception
Inserting Data Into Ms Access Thru JDBC