wood burning stoves*
The moose likes JDBC and the fly likes Insert row replacing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Insert row replacing" Watch "Insert row replacing" New topic
Author

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

mysql-merge-gone-awry
multi-row-merge-in-mysql

Regards,

Fatih.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Insert row replacing
 
Similar Threads
How to automate import in MYSQL ?
MYSQL IMPORT
Sending an excel file from a servlet
Its raining in Pune!!!
A research project, CSV Input and Excel Output