As the question implies I need to declare a @var = 1 variable in a MySQL events as :
DELIMITER $
SET @check_before_update = 1 $
DROP EVENT IF EXISTS expire_product_from_shop $
CREATE
EVENT IF NOT EXISTS expire_product_from_shop
ON SCHEDULE EVERY 2 MINUTE STARTS now()
DO BEGIN
SET @check_before_update = 0;
UPDATE Xdb.shop_product_m2m as m2m
SET m2m.expired=1 WHERE m2m.expires <= now();
SET @check_before_update = 1;
END $
DELIMITER ;
So that when I use a trigger I can resist an update trigger "before update" as :
DROP TRIGGER IF EXISTS shop_product_m2m_before_update $
CREATE TRIGGER shop_product_m2m_before_update
BEFORE UPDATE ON shop_product_m2m
FOR EACH ROW
BEGIN
IF @check_before_update != 0 THEN
SET NEW.modified = NOW();
SET NEW.expired = 0;
SET NEW.expires =ADDDATE(NEW.modified, INTERVAL 15 DAY);
END IF ;
END$
I want a session variable that is set from an event and found when a trigger is being fired because of the event.. As you can notice in the question: I'm trying to run an event and that event causing a before update trigger to be fired ! For which my some other intention is being violated. To prevent that I will need that @check_before_update variable. Thanx