DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`collectionVolumetry_afterUpdate` AFTER UPDATE ON `collectionVolumetry` FOR EACH ROW BEGIN DECLARE vJSON JSON DEFAULT JSON_OBJECT(); DECLARE vUserFk INT DEFAULT account.myUser_getId(); IF NOT (NEW.id <=> OLD.id) THEN SET vJSON = JSON_MERGE(JSON_OBJECT('id', NEW.id), vJSON); END IF; IF NOT (NEW.`level` <=> OLD.`level`) THEN SET vJSON = JSON_MERGE(JSON_OBJECT('level', NEW.`level`), vJSON); END IF; IF NOT (NEW.`lines` <=> OLD.`lines`) THEN SET vJSON = JSON_MERGE(JSON_OBJECT('lines', NEW.`lines`), vJSON); END IF; IF NOT (NEW.liters <=> OLD.liters) THEN SET vJSON = JSON_MERGE(JSON_OBJECT('liters', NEW.liters), vJSON); END IF; IF NOT (NEW.height <=> OLD.height) THEN SET vJSON = JSON_MERGE(JSON_OBJECT('height', NEW.height), vJSON); END IF; IF NOT (NEW.itemPackingTypeFk <=> OLD.itemPackingTypeFk) THEN SET vJSON = JSON_MERGE(JSON_OBJECT('itemPackingTypeFk', NEW.itemPackingTypeFk), vJSON); END IF; IF NOT (NEW.trainFk <=> OLD.trainFk) THEN SET vJSON = JSON_MERGE(JSON_OBJECT('trainFk', NEW.trainFk), vJSON); END IF; SET vJSON = JSON_MERGE(JSON_OBJECT('userFk', vUserFk), vJSON); SET vJSON = JSON_MERGE(JSON_OBJECT('action', 'update'), vJSON); SET vJSON = util.notification_send( 'modified-collection-volumetry', JSON_OBJECT('data', JSON_EXTRACT(vJSON, '$')), vUserFk ); END$$ DELIMITER ;