Re: trigger
Thriggers cannot modify the same table, but try to use BEFORE triggers to change NEW values.
CREATE TABLE t(
id INT(11) NOT NULL AUTO_INCREMENT,
active BIT(1) DEFAULT NULL,
end DATE DEFAULT NULL,
PRIMARY KEY (id)
);
DELIMITER $$
CREATE TRIGGER trigger1
BEFORE UPDATE
ON t
FOR EACH ROW
BEGIN
IF NEW.end IS NOT NULL THEN
SET NEW.active = 1;
END IF;
END
$$
CREATE TRIGGER trigger2
BEFORE INSERT
ON t
FOR EACH ROW
BEGIN
IF NEW.end IS NOT NULL THEN
SET NEW.active = 1;
END IF;
END
$$
DELIMITER ;
Devart Company,
MySQL management tools
http://www.devart.com/dbforge/mysql/
Subject
Views
Written By
Posted
2024
February 02, 2011 02:10PM
Re: trigger
1037
February 03, 2011 06:13AM
1012
February 03, 2011 07:45AM
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.