Trigger creates duplicate records

0

The "update" trigger in Mysql creates 8 records with each update. The first record is the old record, the next 7 are copies of the change. How do I leave only the old and the edited?

I tried to put a UNIQUE key in the datetime of the "historical" table, but it generates an error. But that is not the solution I need either. I can not name a unique key, since the same record can be changed multiple times.

Code entered in PhpMyAdmin:

DROP TRIGGER IF EXISTS 'placasptc'.'update_bds'//
CREATE TRIGGER 'placasptc'.'update_bds' BEFORE UPDATE ON 'placasptc'.'bds'
 FOR EACH ROW begin
insert into historico
set hist_action ='update',
bkp_ID = old.ID,
bkp_empresa = old.empresa,
bkp_prefixo = old.prefixo,
bkp_placa = old.placa,
hist_modificado = now(),
hist_usuario = Current_user();
end
    
asked by anonymous 23.05.2018 / 09:00

0 answers