Good, I am trying to make a trigger with MySql, the problem is that I have always worked with Sql-Server and now I am having some complications. From the following code what is wrong with me? :
USE 'test_db';
DELIMITER
$$
CREATE TRIGGER 'tr_insert_customer' AFTER INSERT ON purchases FOR EACH ROW
BEGIN
DECLARE @usuario varchar(30), @accion varchar(6), @customer varchar(8)
SET @usuario = (SELECT Cus_User FROM INSERTED)
SET @accion = 'creado';
SET @customer = (SELECT Cus_Id FROM INSERTED)
INSERT INTO his_cus (HCu_Action, HCu_User, HCu_Cus_Id) VALUES(@accion,@usuario,@customer)
END;
$$
When trying to create it (with phpMyAdmin) the following error occurs: #1064 - Algo está equivocado en su sintax cerca '@usuario varchar(30), @accion varchar(6), @customer varchar(8)SET @usuario' en la linea 5
What the trigger does in case it helps is to obtain the data of INSERT
and insert them in another table as a history of user actions