As I tested out the code from our last blog, discovered a nice MySQL safety net.
BTW, that blog is here.
The error reads:
You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
Review code and identify DML operations ( Update, Delete ) where the key column is not being filtered on.
Here are possible scenarios that will raise this error :-
- Delete from [table];
- Delete from [table] where [id] > 0;
In our case we replaced
delete from tblIndexColumn
truncate table tblColumn;
SET SQL_SAFE_UPDATES=0; call listIndexColumns(); SET SQL_SAFE_UPDATES=1;