List:General Discussion« Previous MessageNext Message »
From:Keith Edmunds Date:June 5 2009 11:56am
Subject:Trigger and "Warning: #1265 Data truncated"
View as plain text  
I'm very new to triggers, so I suspect I've done something naive. 

When a row is inserted into a table, I want populate a 'date' column with
the date 45 days hence. I've created a trigger: 

CREATE TRIGGER `test`.`setExpiryDate` BEFORE INSERT ON `test`.`mysql_auth` 
FOR EACH ROW SET NEW.expires = curdate()+interval 45 day 

It works, doing what I want, but I get the following error: 

Warning: #1265 Data truncated for column 'expires' at row 1 

The table is:

CREATE TABLE `mysql_auth` ( 
`id` int(11) NOT NULL auto_increment, 
`user` varchar(25) NOT NULL, 
`password` varchar(32) NOT NULL, 
`expires` date NOT NULL, 
`login_failures` int(11) NOT NULL default '0', 
`last_login_failure` datetime default NULL, 
PRIMARY KEY (`id`) 
)

Can someone help me understand what it happening here, and how to fix it? 

Thanks
Thread
Trigger and "Warning: #1265 Data truncated"Keith Edmunds5 Jun
  • Re: Trigger and "Warning: #1265 Data truncated"Walter Heck - OlinData.com5 Jun
    • Re: Trigger and "Warning: #1265 Data truncated"Keith Edmunds9 Jun