dsoihsnz85757 2014-10-21 20:40
浏览 47
已采纳

在更新时创建简单的MySQL触发器的麻烦

(Edit: Apologies for the funky formatting. SO was not having my code formatted.)

I feel dumb, but i've been racking my brain for this for longer then I like to admit.

I need a trigger that, when any update to menu_button is made, it updates a field in soa_config to the datetime the update was made (parameterValue is a Varchar). I've tried doing it as simple as setting parameterValue='1', no dice either. Running the update by itself, and the trigger, sans everything, and both work. It's the combination of the two that makes it hard. I get the 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 'END' at line 1".

    delimiter |
    CREATE TRIGGER imatrigger AFTER UPDATE on `menu_button`
    FOR EACH ROW
    BEGIN
    UPDATE soa_config 
    SET parameter_value = 'CURRENT_TIMESTAMP'
    WHERE parameter_name = last_menu_update_itme

    END
    |
    delimiter ;

I've looked at: Quick MySQL Trigger Update

Trouble in creating Trigger in MySQL

MYSQL trigger trouble

sql creating a trigger on update

and more googling.

  • 写回答

1条回答 默认 最新

  • duanping1632 2014-10-21 21:16
    关注

    You need a statement delimiter after the WHERE clause and before the END statement

    i.e. you should have a semi-colon here: WHERE parameter_name = last_menu_update_itme; <----

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试