2
I don’t know much about Mysql and need to make a Trigger to update a line right after its insertion. When the user registers an order he selects how many orders he wants. In the database is saved in one column the type and in another column the quantity he requested. I wish that every time I enter a new request to my Rigger upgrade the type field to (quantity-type) My Rigger is like this but nothing happens after inserting new record:
delimiter $$
create trigger Atualiza_Pedido
after insert on loja.pedido for each row
Begin
if new.method = 'metodo'
then
update loja.pedido
set tipo = concat(new.quantidade,'-', new.tipo)
where id = new.id;
end if;
END$$
I made these changes and made a mistake saying that the type field was not declared. I then added a declare type varchar (30). I made a new request but the field did not update.
– VictorP
take off the
declare tipo varchar(30)
and in place ofset tipo
placeset new.tipo
, I’ll change in response too.– Roberto de Campos
also didn’t work yet. I tried old but it doesn’t even allow... it’s before Insert even?
– VictorP