在这里,我想将 X 表的内容复制到 Y 表中,并且在同一行上,我想从 X 表中删除该行。我按以下方式尝试了它,但它不起作用。
Drop trigger if exists myTrigger;
delimiter |
create trigger myTrigger
after insert on X
for each row
BEGIN
IF STRCMP(NEW.SysLogTag,"kernel:") = 0 THEN
INSERT INTO Y(logtime,moduleid,severity,messageid,message) values(NULL,1,1,100,NEW.Message);
ELSEIF NEW.SysLogTag like 'ntpd[%]:' THEN
INSERT INTO Y(logtime,moduleid,severity,messageid,message) values(NULL,6,1,100,NEW.Message);
ELSE
INSERT INTO Y(logtime,moduleid,severity,messageid,message) values(NULL,4,1,100,NEW.Message);
END IF;
delete from X where ID=NEW.ID; //Not working.
END;|
delimiter ;