0
When I insert this Rigger into my database it is taking a slow time, getting to give this message:
Errormessage: Lock Wait timeout exceeded; Try restarting transaction
My Trigger is as below, the cod_prod field of the products table is indexed correctly.
DELIMITER //
CREATE TRIGGER ESTOQUEENTRADA
BEFORE INSERT
ON estoque FOR EACH ROW
BEGIN
UPDATE produtos SET quant_estoque = quant_estoque + NEW.quant_prod WHERE cod_prod = NEW.cod_prod;
END;//
DELIMITER;
Take a look here, sometimes it helps you: https://dba.stackexchange.com/questions/100506/why-update-trigger-makes-insertion-slow-in-mysql
– rbz
Thanks for the help, but I checked all the items mentioned in the list and my script was not with any of the problems cited.
– Victor M.
Have you tried to make the Trigger in the
after
instead of doing in thebefore
?– Pagotti
I tried now in the after, the delay was the same.
– Victor M.
I noticed that this only happens if the query is inside a transaction.
– Victor M.