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 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)