IF and CASE in insert query
Don't mix 

CASE value WHEN [compare_value] THEN result
          [WHEN [compare_value] THEN result ...]
          [ELSE result] END


and 

IF(expr1,expr2,expr3)


syntaxes.

See the manual