salix/db/routines/vn/procedures/ticketStateToday_setState.sql

31 lines
692 B
MySQL
Raw Permalink Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketStateToday_setState`(vTicketFk INT, vStateCode VARCHAR(45))
BEGIN
/* Modifica el estado de un ticket de hoy
*
* @param vTicketFk el id del ticket
* @param vStateCode estado a modificar del ticket
*
*/
DECLARE vAlertLevel INT;
DECLARE vAlertLevelPacked INT;
SELECT s.alertLevel, al.id
INTO vAlertLevel, vAlertLevelPacked
FROM state s
JOIN ticketStateToday tst ON tst.state = s.id
JOIN alertLevel al ON al.code = 'PACKED'
2024-01-25 16:33:54 +00:00
WHERE tst.ticketFk = vTicketFk
LIMIT 1;
IF vAlertLevel < vAlertLevelPacked THEN
CALL vn.ticket_setState(vTicketFk, vStateCode);
END IF;
END$$
DELIMITER ;