-1

This is my first time using mysql and I am tying to learn how to use trigger.

Im using navicat, i go to table design and then go triggers tab. I create a trigger named testing and in definition I typed:

delimiter |
  CREATE TRIGGER lpr.mytesting AFTER INSERT ON lpr.lpr_opt_upload 
    FOR EACH ROW BEGIN
      set new.lpr_text := reverse(new.lpr_text);
    END;
| delimiter ;

All im tying to do is whenever something new is inserted, I reverse the text in lpr_text field. However, i get "1064 - you have an error in your SQL; check the manual that corresponds o your MySql server version for the right syntax to yse 'ON lpr_opt_upload' FOR EACH ROW create trigger testing before insert on lpr_op' at line 1." I dont understand what Im doing wrong, I am just copying an trigger example.

//-------------------------------------------------------------------------//

I figured out the problem. I am using navicat and in navicat trigger tab, you only type the body into the definition, Not the header (ex: CREATE TRIGGER lpr.mytesting AFTER INSERT ON lpr.lpr_opt_upload). There are check box next to the name of your trigger and you use those instead of writing your own header.

4

1 回答 1

1

DELIMITER命令是一个客户端命令,并非所有客户端都支持(它根本不会发送到服务器,它只是指示客户端如何区分语句以便将它们正确发送到服务器)。MySQL 手册中对它的引用假定您使用的是“官方”MySQL 客户端,例如mysql命令行工具或 MySQL Workbench(两者都支持该DELIMITER命令)。

我不知道如何更改 Navicat 中的语句分隔符,但这是您问题的根源。

于 2012-05-21T20:17:10.707 回答