I created the following trigger in Mysql:
DELIMITER //
CREATE TRIGGER delete_G8_dados_indicadores_antes_insert
BEFORE INSERT
ON G8_dados_indicadores FOR EACH ROW
BEGIN
delete from G8_dados_indicadores where id_indicador=NEW.id_indicador and ano = NEW.ano;
END; //
DELIMITER ;
The idea is that before entering a record in G8_dados_indicadores table, the system triggers the trigger automatically removing existing records. But to run an insert, mysql returns the following error:
1442 - Can't update table 'G8_dados_indicadores' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
What can it be?