I have the following table and trigger but the trigger isn't setting the create_dt value to now() on the insert event:
CREATE TABLE `user` (
`user_id` int(10) NOT NULL auto_increment,
`user_name` varchar(255) NOT NULL default '',
`password` varchar(255) NOT NULL default '',
`first_name` varchar(255) NOT NULL default '',
`last_name` varchar(255) NOT NULL default '',
`email` varchar(255) NOT NULL default '',
`modify_by` int(10) NOT NULL default '1',
`modify_dt` timestamp NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`create_by` int(10) NOT NULL default '1',
`create_dt` datetime NOT NULL default '0000-00-00 00:00:00',
`active` enum('Yes','No') NOT NULL default 'No',
PRIMARY KEY (`user_id`),
UNIQUE KEY `user_name` (`user_name`),
UNIQUE KEY `email` (`email`),
FOREIGN KEY (`modify_by`) REFERENCES `user`(`user_id`),
FOREIGN KEY (`create_by`) REFERENCES `user`(`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;
CREATE TRIGGER ins_user BEFORE INSERT ON `user` FOR EACH ROW SET @create_dt = NOW();
I've tried both BEFORE and AFTER trigger action time but no change. Does anyone have any suggestions?
The goal is to have the create_dt value set with a date_time NOW() value on insert.