Mailing List
Home
Forum Home
MySQL General - General MySQL discussion
MySQL++ - Programming with the C++ API to MySQL
MaxDB - Everything about MaxDB, formerly known as SAP DB
ODBC - ODBC with the MySQL Connector/ODBC driver
MySQL on Win32 - Runing MySQL on Windows 9x/Me/NT/2000/XP
Java Help - Mostly related to the MySQL Connector/J driver
Perl - Perl support for MySQL with DBI and DBD::mysql
GUI - MySQL GUI Tools
Announcement
Subjects
mysql openssl Question
ERROR 1045: Access denied for user: 'root@localhost ' (Using
password: NO)
Update one field with more fields from another table
Getting Identity after INSERT
ERROR 2002: Can 't connect to local MySQL server through socket
mysql test 4 1 fails with the gis test
MySQL Cluster Software
Downgrade Mysql from 4 to 3 23
Mysql 4 0 Oracle Stored Procedure Trigger Conversion
Can 't access mysql after kernel upgrade
Executing MySQL Commands From Within C Program
Comparing and writing out BLOBS
Preventing Duplicate Entries
FULLTEXT query format question
Strange behavior, Table Level Permission
Does the binary log enabling affect the MySQL performances?
mysql:it 's a db not a dbms how it 's possible?!
mysql have same function mthod as Oracle decode()
 
Trigger

Trigger

2007-10-11       - By Patricio A. Bruna

 Back
Hi,
I have a problem with a trigger which should conver a unix timestamp to a MySQL
date datatype.
The trigger works if the column is varchar, but when the column is date type,
it write the date of 1969-31-12.
Any ideas?



DROP TABLE IF EXISTS `visitas`;
CREATE TABLE `visitas` (
`id` int(11) NOT NULL auto_increment,
`date` varchar(25) default NULL,
`elapsed` int default NULL,
`src_ip` varchar(15) default NULL,
`result_code` varchar(25) default NULL,
`http_status` TINYINT default NULL,
`bytes` int default NULL,
`request` varchar(50) default NULL,
`authname` varchar(10) default NULL,
`type` varchar(20) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

/*!50003 SET @(protected)=@@(protected)*/;
DELIMITER ;;
/*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES" */;;
/*!50003 CREATE */ /*!50017 DEFINER=`root`@`localhost` */ /*!50003 TRIGGER
`unix2normaltime` BEFORE INSERT ON `visitas` FOR EACH ROW begin
set New.date=date(from_unixtime(New.date));
end */;;

When