我有一个非常大的文件,可以创建我自动生成的触发器。但是我无法通过第3行。
Php版本5.3.2 Mysql版本14.14 Distrib 5.1.41
以下是前几行:
1 delimiter $$
2 -- CompanyTitleHolder
3 -- Create INSERT event for CompanyTitleHolder
4 CREATE OR REPLACE TRIGGER trigger_insert_CompanyTitleHolder AFTER INSERT ON CompanyTitleHolder
5 FOR EACH ROW
6 BEGIN
7
8 IF(NEW.CompanyTitleHolderID <> '') OR (NEW.CompanyTitleHolderID IS NOT NULL) THEN
9 CALL add_Audit (@UserName, "CompanyTitleHolder", "CompanyTitleHolderID", "--new record--", NEW.CompanyTitleHolderID);
10 END IF;
11 -- This goes on for quite a while
?? END;$$
?? delimiter ;
这就是错误:
/* SQL Error (1064): 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 'TRIGGER trigger_insert_CompanyTitleHolder AFTER INSERT ON CompanyTitleHolder F' at line 3 */
我正在尝试使用this method and code作为我的基础
来执行审核表答案 0 :(得分:1)
CREATE OR REPLACE
似乎在MySQL中不起作用,它是Old Bug。您必须在DROP TRIGGER IF EXISTS
声明之前执行CREATE TRIGGER
。
答案 1 :(得分:1)
MySQL不支持OR REPLACE
:http://dev.mysql.com/doc/refman/5.6/en/create-trigger.html
答案 2 :(得分:1)
你不能CREATE OR REPLACE
。
尝试:
DROP TRIGGER IF EXISTS trigger_insert_CompanyTitleHolder;
CREATE TRIGGER trigger_insert_CompanyTitleHolder AFTER INSERT ON CompanyTitleHolder
...