MySQL: DECLARE CONTINUE HANDLER to continue on errors, printing a warning -


I am reviewing / redesigning / refactoring a database and want to create a new database which is a smart data Keeps in Fashion One of the problems of the 'legacy' database is that it does not make proper use of the keys and indices, so there are duplicate entries where no one should be.

I've written a dragon script that reads data from legacy database and generates a SQL script, which in turn incorporates these databases from a legacy database into a new database using lots of SQL INSERT statements Does. SQL scripts face duplicate entries every time an error message

ERROR 1062 (23000) on line 3086: key 'lat_lon_height' for '56.40000000 - 3.366670000-121' duplicate entry

The AFAICT is absolutely right what he should do. However, for this moment, I should just continue the script, do not include duplicate entries, but print a warning about them. I tried to set up a running handler to continue in the various ways in the beginning of the screen, but, all of them make just one syntax error:

  1062 selection to continue to decline Duplicate key in unique index '; Select SQLSTATE '23000' 'duplicate key in unique index'; Set the SQLSTATE '23000'  

or

   

or

 Start the handler for 'Select duplicate key in unique index'; End;  

What am I doing?

I do not have handlers used in addition to stored procedures where their use is limited but unbeatable. Maybe you can make your code in a stored procedure and then run the stored procedure? You may accept MySQL that you are trying to do so.


Comments