0
Could someone please tell me where I’m going wrong with my Rigger’s creation
Trigger
$sql = "DELIMITER $$
CREATE TRIGGER produtos_movto_insert AFTER INSERT ON produtos_movto
FOR EACH ROW
BEGIN
IF NEW.prmv_maismenos = '+' THEN
UPDATE produtos SET prod_qte_estoque = (prod_qte_estoque + NEW.prmv_qte) WHERE idprodutos = NEW.prmv_idprodutos;
END IF;
IF NEW.prmv_maismenos = '-' THEN
UPDATE produtos SET prod_qte_estoque = (prod_qte_estoque - NEW.prmv_qte) WHERE idprodutos = NEW.prmv_idprodutos;
END IF;
END
$$";
Error
Erro: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER $$ CREATE TRIGGER produtos_movto_insert AFTER INSERT ON produtos' at line 1
It is stored in a php variable and is executed by php
you can tell which is the error, the line?
– Ricardo Pontual
@Ricardopunctual I edited the question and put the error there
– Vinicius Fernandes
I’m a little rusty, but I think we’re missing one
;
after theEND
and before the$$
(at the end of the syntax)?– Guilherme Nascimento
@Ricardopunctual I just put the
;
lastEND
but the error persisted– Vinicius Fernandes