开发者

Mysql trigger syntax error 1064

I have a very large file that creates triggers that I auto generated. However I'm not able to get passed line 3.

Php version 5.3.2 Mysql Version 14.14 Distrib 5.1.41

Here are the first few lines:

  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 ;

And this is the e开发者_Python百科rror:

/* 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 */

I'm trying to do an audit table using this method and code as my base


MySQL doesn't support OR REPLACE: http://dev.mysql.com/doc/refman/5.6/en/create-trigger.html


CREATE OR REPLACE doesn't seem to work in MySQL, it's an Old Bug. You'll have to do a DROP TRIGGER IF EXISTS before your CREATE TRIGGER statement.


You can't CREATE OR REPLACE.

Try:

DROP TRIGGER IF EXISTS trigger_insert_CompanyTitleHolder;

CREATE TRIGGER trigger_insert_CompanyTitleHolder AFTER INSERT ON CompanyTitleHolder 
...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜