Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have,
SQL
LOAD DATA LOCAL INFILE 'C:\Users\mydesk\Desktop\dcc.csv' INTO TABLE DATAS.TABLE IN FIELDS TERMINATED BY ',' ENCLOSED BY '"' lines terminated by '\n'

query in my program, to upload data from csv file to mysql. But there will be "Duplicate entry for PRIMARY KEY" error in some rows and. How can I catch those exception in each row and handle with different query?
For example I have 10rows in csv file, and some of the rows are same as in DATAS.TABLE. So When such records coming for insert into the table DATAS.TABLE, I need to execute update query instead.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900