I created the following trigger, but it has a syntax error that I can not find.
The error is as follows
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'on rev_reviews AFTER INSERT AS BEGIN DECLARE @totalItens int DECLARE @revis' at line 1
the trigger is this:
CREATE TRIGGER insertReview
on rev_reviews
AFTER INSERT
AS
BEGIN
DECLARE @totalItens int
DECLARE @revisado varchar(4)
DECLARE @countRevisado int
DECLARE @ean varchar(4)
DECLARE @countEan int
select count(1) into @totalItens from rev_reviews where task_id = new.task_id
select @revisado = revisado, @ean = ean_existe from rev_reviews where id = new.id
select @countRevisado = count(1) from rev_reviews where task_id = new.task_id AND Revisado LIKE @revisado
select @countEan = count(1) from rev_reviews where task_id = new.task_id AND ean_existe LIKE @ean;
CASE
WHEN @ean == 'Sim' THEN
CASE
WHEN @revisado == 'Nao'
THEN update rev_tasks set totalItens = @totalItens, totalPen = @countRevisado, totalEan = @countEan where id = new.task_id
WHEN @revisado == 'Sim'
THEN update rev_tasks set totalItens = @totalItens, totalRev = @countRevisado, totalEan = @countEan where id = new.task_id
WHEN @revisado == 'NR'
THEN update rev_tasks set totalItens = @totalItens, totalNr = @countRevisado, totalEan = @countEan where id = new.task_id
WHEN @revisado == 'Aut'
THEN update rev_tasks set totalItens = @totalItens, totalAut = @countRevisado, totalEan = @countEan where id = new.task_id
END
ELSE
CASE
WHEN @revisado == 'Nao'
THEN update rev_tasks set totalItens = @totalItens, totalPen = @countRevisado, totalNEan = @countEan where id = new.task_id
WHEN @revisado == 'Sim'
THEN update rev_tasks set totalItens = @totalItens, totalRev = @countRevisado, totalNEan = @countEan where id = new.task_id
WHEN @revisado == 'NR'
THEN update rev_tasks set totalItens = @totalItens, totalNr = @countRevisado, totalNEan = @countEan where id = new.task_id
WHEN @revisado == 'Aut'
THEN update rev_tasks set totalItens = @totalItens, totalAut = @countRevisado, totalNEan = @countEan where id = new.task_id
END
END
END
Thanks in advance.