This commit is contained in:
parent
811a49275d
commit
791687f271
|
@ -4,6 +4,10 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `VN_SCHEDULER`
|
||||||
STARTS CURRENT_TIMESTAMP + INTERVAL 1 DAY
|
STARTS CURRENT_TIMESTAMP + INTERVAL 1 DAY
|
||||||
ENABLE
|
ENABLE
|
||||||
DO BEGIN
|
DO BEGIN
|
||||||
|
/**
|
||||||
|
* Ejecuta el PROCEDURE que comprueba si hay procedimientos planificados para ejecutar
|
||||||
|
*
|
||||||
|
*/
|
||||||
CALL `VN_SCHEDULER`();
|
CALL `VN_SCHEDULER`();
|
||||||
END$$
|
END$$
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,27 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`VN_SCHEDULER`()
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`VN_SCHEDULER`()
|
||||||
BEGIN
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Ejecuta los procedimientos que se han programado a demanda.
|
||||||
|
*
|
||||||
|
*/
|
||||||
DECLARE vDone BOOL;
|
DECLARE vDone BOOL;
|
||||||
DECLARE vError VARCHAR(255) DEFAULT NULL;
|
DECLARE vError VARCHAR(255) DEFAULT NULL;
|
||||||
DECLARE vErrorCode VARCHAR(255) DEFAULT NULL;
|
DECLARE vErrorCode VARCHAR(255) DEFAULT NULL;
|
||||||
DECLARE vSchema VARCHAR(255);
|
DECLARE vSchema VARCHAR(255);
|
||||||
DECLARE vStatus VARCHAR(255);
|
DECLARE vStatus VARCHAR(255);
|
||||||
DECLARE vProcedure VARCHAR(255);
|
DECLARE vProcedure VARCHAR(255);
|
||||||
-- DECLARE vLogMail VARCHAR(255);
|
|
||||||
DECLARE vScheduleFk INT;
|
DECLARE vScheduleFk INT;
|
||||||
-- Obtener datos de la tabla vn_schedules
|
-- Obtener datos de la tabla vn_schedules
|
||||||
DECLARE vQueue CURSOR FOR
|
DECLARE vQueue CURSOR FOR
|
||||||
SELECT id, `schema`, `procedure`, `status`
|
SELECT id, `schema`, `procedure`, `status`
|
||||||
FROM vn_schedules
|
FROM vn_schedules
|
||||||
WHERE status = 'scheduled';
|
WHERE status = 'scheduled';
|
||||||
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||||
|
GET DIAGNOSTICS CONDITION 1
|
||||||
|
vError = MESSAGE_TEXT,
|
||||||
|
vErrorCode = RETURNED_SQLSTATE;
|
||||||
OPEN vQueue;
|
OPEN vQueue;
|
||||||
l: LOOP
|
l: LOOP
|
||||||
SET vDone = FALSE;
|
SET vDone = FALSE;
|
||||||
|
@ -32,10 +39,7 @@ BEGIN
|
||||||
WHERE id = vScheduleFk;
|
WHERE id = vScheduleFk;
|
||||||
|
|
||||||
SET vError = NULL;
|
SET vError = NULL;
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
|
||||||
GET DIAGNOSTICS CONDITION 1
|
|
||||||
vError = MESSAGE_TEXT,
|
|
||||||
vErrorCode = RETURNED_SQLSTATE;
|
|
||||||
|
|
||||||
CALL util.exec(CONCAT('CALL `', vSchema ,'`.`', vProcedure ,'`'));
|
CALL util.exec(CONCAT('CALL `', vSchema ,'`.`', vProcedure ,'`'));
|
||||||
|
|
||||||
|
@ -55,14 +59,14 @@ BEGIN
|
||||||
UPDATE vn_schedules
|
UPDATE vn_schedules
|
||||||
SET `error` = vError,
|
SET `error` = vError,
|
||||||
finished = util.VN_NOW(),
|
finished = util.VN_NOW(),
|
||||||
lastFinished = util.VN_NOW()
|
lastFinished = util.VN_NOW(),
|
||||||
`errorCode` = vErrorCode
|
`errorCode` = vErrorCode,
|
||||||
`status` = 'error'
|
`status` = 'error'
|
||||||
WHERE id = vScheduleFk;
|
WHERE id = vScheduleFk;
|
||||||
ELSE
|
ELSE
|
||||||
UPDATE vn_schedules
|
UPDATE vn_schedules
|
||||||
SET `error` = vError,
|
SET `error` = vError,
|
||||||
`errorCode` = vErrorCode
|
`errorCode` = vErrorCode,
|
||||||
finished = util.VN_NOW(),
|
finished = util.VN_NOW(),
|
||||||
lastFinished = util.VN_NOW(),
|
lastFinished = util.VN_NOW(),
|
||||||
`status` = 'exec'
|
`status` = 'exec'
|
||||||
|
|
|
@ -9,12 +9,11 @@ BEGIN
|
||||||
`changedModelId` = OLD.zoneFk,
|
`changedModelId` = OLD.zoneFk,
|
||||||
`userFk` = account.myUser_getId();
|
`userFk` = account.myUser_getId();
|
||||||
|
|
||||||
-- Activo el evento 'zone_getCollisions'
|
-- Inserta en vn_schedules para ejecutar el procedure de 'zone_getCollisions'
|
||||||
-- UPDATE `mysql`.`event` SET status = 1 WHERE name = 'zone_getCollisions';
|
|
||||||
INSERT IGNORE INTO `util`.`vn_schedules`(`schema`, `procedure`)
|
INSERT IGNORE INTO `util`.`vn_schedules`(`schema`, `procedure`)
|
||||||
VALUES
|
VALUES
|
||||||
(`vn`, `zone_getCollisions`);
|
('vn', 'zone_getCollisions');
|
||||||
|
|
||||||
-- Insert en vn_schedules 'zone_getCollisions'
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeInsert`
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeInsert`
|
||||||
BEFORE INSERT ON `zoneIncluded`
|
BEFORE INSERT ON `zoneIncluded`
|
||||||
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
|
|
||||||
-- Activo el evento 'zone_getCollisions'
|
-- Inserta en vn_schedules para ejecutar el procedure de 'zone_getCollisions'
|
||||||
-- Insert en vn_schedulesla key 'zone_getCollisions'
|
|
||||||
-- ALTER EVENT zoneCollisions ENABLE;
|
|
||||||
INSERT IGNORE INTO `util`.`vn_schedules`(`schema`, `procedure`)
|
INSERT IGNORE INTO `util`.`vn_schedules`(`schema`, `procedure`)
|
||||||
VALUES
|
VALUES
|
||||||
(`vn`, `zone_getCollisions`);
|
('vn', 'zone_getCollisions');
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -5,10 +5,10 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_beforeUp
|
||||||
BEGIN
|
BEGIN
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
|
|
||||||
-- Activo el evento 'zone_getCollisions' -- Insert en vn_schedules 'zone_getCollisions'
|
-- Inserta en vn_schedules para ejecutar el procedure de 'zone_getCollisions'
|
||||||
|
|
||||||
INSERT IGNORE INTO `util`.`vn_schedules`(`schema`, `procedure`)
|
INSERT IGNORE INTO `util`.`vn_schedules`(`schema`, `procedure`)
|
||||||
VALUES
|
VALUES
|
||||||
(`vn`, `zone_getCollisions`);
|
('vn', 'zone_getCollisions');
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
Loading…
Reference in New Issue