I’m trying to create this trigger and I get this error:
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 'case where artcStackId = new.artcStackId' at line 7
Here is the failing trigger
SET new.artcPublicId =
case
when new.artcCountry = 'US' then concat(91,new.artcStackId)
when new.artcCountry = 'UK' then concat(92,new.artcStackId)
when new.artcCountry = 'CA' then concat(93,new.artcStackId)
else concat(11,new.artcStackId)
end case
where artcStackId = new.artcStackId
Here is the trigger that works
SET new.artcPublicId =
case
when new.artcCountry = 'US' then concat(91,new.artcStackId)
when new.artcCountry = 'UK' then concat(92,new.artcStackId)
when new.artcCountry = 'CA' then concat(93,new.artcStackId)
else concat(11,new.artcStackId)
end
when I add those extra bits, it’ll fail.
There is no reference to your where condition.i think it should be like
where new.artcStackId = new.artcStackId