このトリガーを作成しようとすると、次のエラーが発生します。
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
これが失敗したトリガーです
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
これが機能するトリガーです
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
これらの余分なビットを追加すると、失敗します。