3
Hello, when I try to run the following Rigger, I get this error:
#1064 - You have a syntax error in your SQL next to line 11
Follow the Trigger:
CREATE TRIGGER atualizacao
after update ON cliente
FOR EACH ROW
BEGIN
DECLARE VERX VARCHAR(10);
SET VERX=(SELECT DESCRICAO FROM versao WHERE id=NEW.id_versao);
if(OLD.id_versao<NEW.id_versao)then
begin
INSERT INTO tarefa (id_cliente,id_servico,dt_cadastro,dt_inicio,dt_final,hora_inicio,hora_final,situacao,descricao,solucao,prioridade,id_projeto,tipo) VALUES(NEW.id_cliente,10,now(),now(),now(),now(),now(),2,'Atualização',CONCAT('Sistema atualizado para versão ',VERX),1,1,0);
end;
END$$
I wonder what it could be...
Which line 11? Would be the line "END$$"?
– Boneco Sinforoso
Your select is not missing JOIN ? where the field WHERE id=NEW.id_version comes from ?
– Edvaldo Lucena
@Edvaldolucena the
NEW.id_versao
is the last changed id, no need for Join– Ricardo Pontual
@Ricardopunctual that’s right, line 11 is the last
– Evaldo Rc
the last line would not be
END;$$
?– Ricardo Pontual
@Ricardopunctual already tried, the same thing happens..
– Evaldo Rc
I believe that there instead of
end;
be itend if;
since you didn’t close theIF
– Patrick Perdigão
I actually believe that there before the
INSERT
nor is it necessary to open a newbegin
– Patrick Perdigão
@Evaldorc your Rigger does what? You didn’t detail what she does.
– user141036
Aham, I made the changes (removing Begin and putting end if) and it worked, thank you very much!!
– Evaldo Rc