CREATE TRIGGER 'user_tel' AFTER INSERT ON 'usuarios'
FOR EACH ROW
TROW BEGIN
DECLARE TEL CHAR(14);
DECLARE ID INT;
SET TEL = (SELECT telefono FROM usuarios ORDER BY idUsuario DESC LIMIT 1);
SET ID = (SELECT idUsuario FROM usuarios ORDER BY idUsuario DESC LIMIT 1);
BEGIN
UPDATE usuarios
SET telefono = Cast(Replace(Replace(Replace(Tel,'-',' '),'(',' '),')',' ') As CHAR)
WHERE idUsuario = ID;
END;
END;
This code is to replace the parentheses and the script on the phones
Ex.
(999) 999-9999 by 999 999 9999
but when inserting in the table
I get the following error
1442 - Can not update table 'users' in stored function / trigger because it is already used by statement which invoked this stored
function / trigger.
Could you help me please