0
create trigger tr_af after update on relatorio_notas 
for each row
if (new.Nota < 7) then
insert into aluno_af (nome, matricula) values (new.Nota, new.Matricula_estudante)
end if;

I got syntax error and I don't know why

1 Answer 1

1

You need a BEGIN and END block in your syntax. See the 13.1.11 CREATE TRIGGER Syntax:

create trigger tr_af after update on relatorio_notas
for each row
begin               # <-------------------
  if (new.Nota < 7) then
  insert into aluno_af (nome, matricula) values (new.Nota, new.Matricula_estudante);
  end if;
end                 # <-------------------

Note you may need to set the delimiter to something different than ;.

See more info in MySQL syntax check or a sample in Trigger syntax and IF ELSE THEN.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.