我在Windows XP上运行MySQL5.1.48,以下触发器测试不起作用:
DROP TABLE IF EXISTS `ikasan01`.`ikasanwiretap`;
CREATE TABLE `ikasan01`.`ikasanwiretap` (
`Id` bigint(20) NOT NULL AUTO_INCREMENT,
`ModuleName` varchar(255) NOT NULL,
`FlowName` varchar(255) NOT NULL,
`ComponentName` varchar(255) NOT NULL,
`EventId` varchar(255) NOT NULL,
`PayloadId` varchar(255) NOT NULL,
`PayloadContent` varchar(255) NOT NULL,
`CreatedDateTime` datetime NOT NULL,
`UpdatedDateTime` datetime NOT NULL,
`Expiry` datetime NOT NULL,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
have to do it via a BEFORE INSERT TRIGGER
CREATE TRIGGER defaultUpdateDateTime
BEFORE INSERT ON ikasanwiretap FOR EACH ROW
SET NEW.UpdatedDateTime = now();
insert into IkasanWiretap (ModuleName, FlowName, ComponentName,
EventId, PayloadId, PayloadContent, CreatedDateTime, Expiry) values
('3', '3', '3', '3', '3', '3', now(), now());
在我的触发器测试中,我仍然得到MySQL服务器,声明updatedDateTime没有默认值。
我已经尝试了所有我可以支配的事情,所以我想我会问你很多有用的事;)有什么想法吗?
干杯,
马蒂恩
PS:X张贴在伦敦Java用户组和IKASAN EIP邮件列表中。