2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`business_afterUpdate`
|
2024-01-15 11:31:03 +00:00
|
|
|
AFTER UPDATE ON `business`
|
|
|
|
FOR EACH ROW
|
|
|
|
BEGIN
|
2024-09-24 13:43:33 +00:00
|
|
|
DECLARE vIsActive BOOL;
|
|
|
|
DECLARE vExtension VARCHAR(10);
|
2024-09-24 08:15:01 +00:00
|
|
|
|
2024-01-15 11:31:03 +00:00
|
|
|
CALL worker_updateBusiness(NEW.workerFk);
|
|
|
|
|
|
|
|
IF NOT (OLD.workerFk <=> NEW.workerFk) THEN
|
|
|
|
CALL worker_updateBusiness(OLD.workerFk);
|
|
|
|
END IF;
|
2024-09-24 08:15:01 +00:00
|
|
|
|
2024-09-24 13:43:33 +00:00
|
|
|
IF NOT (OLD.departmentFk <=> NEW.departmentFk) THEN
|
|
|
|
SELECT COUNT(*) INTO vIsActive FROM worker WHERE businessFk = NEW.id;
|
|
|
|
IF vIsActive THEN
|
|
|
|
CALL queueMember_updateQueue(NEW.id);
|
|
|
|
END IF;
|
2024-09-24 08:15:01 +00:00
|
|
|
END IF;
|
2024-01-15 11:31:03 +00:00
|
|
|
END$$
|
|
|
|
DELIMITER ;
|