delimiter $$
drop TRIGGER if EXISTS upflttyprateTrig
create TRIGGER upflttyprateTrig
AFTER UPDATE ON flttyprate
FOR EACH ROW BEGIN
INSERT INTO `histflttyprate` (
`flttyprate_Id`,
`flttyprate_Flttyp_Id_Fk`,
`flttyprate_Date_Eff`,
`flttyprate_Date_Ineff`,
`flttyprate_IFR`,
`flttyprate_Single`,
`flttyprate_Multi`,
`flttyprate_Rate_Per_Hr`,
`flttyprate_Night_Surchage`,
`flttyprate_Status`,
`flttyprate_Token`)
VALUES (
NEW.flttyprate_Id,
NEW.flttyprate_Flttyp_Id_Fk,
NEW.flttyprate_Date_Eff,
NEW.flttyprate_Date_Ineff,
NEW.flttyprate_IFR,
NEW.flttyprate_Single,
NEW.flttyprate_Multi,
NEW.flttyprate_Rate_Per_Hr,
NEW.flttyprate_Night_Surchage,
NEW.flttyprate_Status,
NEW.flttyprate_Token);
END$$
不起作用为什么实际的语法是mysqlversion 5.0
答案 0 :(得分:0)
DROP TRIGGER语句中不支持“IF EXISTS”子句。 并在'DROP TRIGGER ...'语句后添加分隔符。
修改强>
从information_schema
。triggers
表中读取有关触发器存在的信息;然后放下触发器。在应用程序中执行此操作或编写存储过程。
示例:
DELIMITER $$
CREATE PROCEDURE drop_trigger()
BEGIN
SET @exist = NULL;
SELECT 1
INTO
@exist
FROM
information_schema.triggers
WHERE
trigger_schema = 'test'
AND trigger_name = 'trigger1';
IF @exist IS NOT NULL THEN
DROP TRIGGER test.trigger1;
END IF;
END
$$
DELIMITER ;