File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Insert row replacing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Insert row replacing" Watch "Insert row replacing" New topic

Insert row replacing

MichaelJ McCabe
Ranch Hand

Joined: Feb 09, 2010
Posts: 49
Please excuse my lack of MySql knowledge here.

Basically, every day I have a CSV file with a weeks worth of data. And every day that passes by, the csv files is automatically edited and removed the last day and adds the new day. So that it always has the LAST weeks data.

I need to parse this data and put it into a database.

The problem is here, obviously, is that if I just parse this data in, there will be duplication. Every day, im adding a new set of data which I parsed for the last 6 days, even though it is identical. Mysql will take a new primary key and add this in as seperate content.

I know the simple answer is to check that the data isnt already there, or to make sure that I only parse the LAST day. But I was thinking to myself, why complicate things, if there was a way of overwritting the data if there is a duplication?
Fatih Keles
Ranch Hand

Joined: Sep 01, 2005
Posts: 182
Hi Michael,

If you can identify a row with some unique constraint mysql offers this and it may help.
For further discussion you may find these useful, mostly the second one



I agree. Here's the link:
subject: Insert row replacing
It's not a secret anymore!