创建触发器错误。在线等待,在线结帖。
语句:
DELIMITER //
CREATE TRIGGER tg_order_status
AFTER UPDATE ON michelin_ntp_2011.ntp_order_1
FOR EACH ROW
BEGIN
UPDATE michelin_ntp_2011.ntp_order_ext SET michelin_ntp_2011.ntp_order_ext.status=NEW.status WHERE michelin_ntp_2011.ntp_order_ext.ofid=NEW.ofid;
END; //
服务器上运行没有任何问题。
自己的电脑上运行(服务器和自己电脑数据库完全一样)。后提示:
您的 SQL 查询可能有错。如果可能的话,以下会列出 MySQL 服务器的错误输出,这可能对您解决问题有一定的帮助作用。
ERROR: 未知的标点符号字符串 @ 11
STR: //
SQL: DELIMITER //
CREATE TRIGGER tg_order_status
AFTER UPDATE ON michelin_ntp_2011.ntp_order_1
FOR EACH ROW
BEGIN
UPDATE michelin_ntp_2011.ntp_order_ext SET michelin_ntp_2011.ntp_order_ext.status=NEW.status WHERE michelin_ntp_2011.ntp_order_ext.ofid=NEW.ofid;DELIMITER //
CREATE TRIGGER tg_order_status
AFTER UPDATE ON michelin_ntp_2011.ntp_order_1
FOR EACH ROW
BEGIN
UPDATE michelin_ntp_2011.ntp_order_ext SET michelin_ntp_2011.ntp_order_ext.status=NEW.status WHERE michelin_ntp_2011.ntp_order_ext.ofid=NEW.ofid;DELIMITER //
CREATE TRIGGER tg_order_status
AFTER UPDATE ON michelin_ntp_2011.ntp_order_1
FOR EACH ROW
BEGIN
UPDATE michelin_ntp_2011.ntp_order_ext SET michelin_ntp_2011.ntp_order_ext.status=NEW.status WHERE michelin_ntp_2011.ntp_order_ext.ofid=NEW.ofid;DELIMITER //
CREATE TRIGGER tg_order_status
AFTER UPDATE ON michelin_ntp_2011.ntp_order_1
FOR EACH ROW
BEGIN
UPDATE michelin_ntp_2011.ntp_order_ext SET michelin_ntp_2011.ntp_order_ext.status=NEW.status WHERE michelin_ntp_2011.ntp_order_ext.ofid=NEW.ofid;
SQL 查询:
DELIMITER // CREATE TRIGGER tg_order_status AFTER UPDATE ON michelin_ntp_2011.ntp_order_1 FOR EACH ROW BEGIN UPDATE michelin_ntp_2011.ntp_order_ext SET michelin_ntp_2011.ntp_order_ext.status=NEW.status WHERE michelin_ntp_2011.ntp_order_ext.ofid=NEW.ofid;
MySQL 返回:文档
#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 'DELIMITER //
CREATE TRIGGER tg_order_status
AFTER UPDATE ON michelin_ntp_2011' at line 1
------解决方案--------------------
DELIMITER //
CREATE TRIGGER tg_order_status AFTER UPDATE ON michelin_ntp_2011.ntp_order_1
FOR EACH ROW
BEGIN
UPDATE michelin_ntp_2011.ntp_order_ext SET michelin_ntp_2011.ntp_order_ext.status=NEW.status WHERE michelin_ntp_2011.ntp_order_ext.ofid=NEW.ofid;
END; //
DELIMITER ;