MySQL Forums
Forum List  »  Triggers

problem with trigger
Posted by: ragen sol
Date: September 03, 2011 05:23AM

below is the trigger I am using for insert event on a table. It is related to a table date_time. I have given the structure of this table below.


DELIMITER $$

DROP TRIGGER /*!50114 IF EXISTS */ `sms_settings`.`insert_datetime`$$

create trigger `sms_settings`.`insert_datetime` AFTER INSERT on `sms_settings`.`date_time`
for each row BEGIN
delete from sms_settings.date_time ;

END;
$$

DELIMITER ;

When I am trying to insert into the table date_time, it is throwing the following error.

Error Code : 1442
Can't update table 'date_time' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.

The structure of my date_time table is

CREATE TABLE `date_time` (
`dt_col` int(11) NOT NULL AUTO_INCREMENT,
`date_time` datetime DEFAULT NULL,
PRIMARY KEY (`dt_col`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1

Thanks in advance

Options: ReplyQuote


Subject
Views
Written By
Posted
problem with trigger
2013
September 03, 2011 05:23AM
1044
September 05, 2011 12:46AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.