2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_setState`(vSelf INT, vStateCode VARCHAR(255) COLLATE utf8_general_ci)
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Modifica el estado de los tickets de una colección.
|
|
|
|
*
|
|
|
|
* @param vSelf el id del colección
|
|
|
|
* @param vStateCode estado a modificar de los tickets
|
|
|
|
*/
|
|
|
|
DECLARE vTicketFk INT;
|
|
|
|
DECLARE vDone INT DEFAULT FALSE;
|
|
|
|
DECLARE vCursor CURSOR FOR
|
|
|
|
SELECT DISTINCT ticketFk
|
|
|
|
FROM ticketCollection tc
|
|
|
|
WHERE tc.collectionFk = vSelf;
|
|
|
|
|
|
|
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
|
|
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
|
|
|
BEGIN
|
|
|
|
ROLLBACK;
|
|
|
|
RESIGNAL;
|
|
|
|
END;
|
|
|
|
|
|
|
|
START TRANSACTION;
|
|
|
|
|
|
|
|
OPEN vCursor;
|
|
|
|
|
|
|
|
read_loop: LOOP
|
|
|
|
|
|
|
|
FETCH vCursor INTO vTicketFk;
|
|
|
|
|
|
|
|
IF vDone THEN
|
|
|
|
LEAVE read_loop;
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
CALL ticket_setState(vTicketFk, vStateCode);
|
|
|
|
|
|
|
|
END LOOP;
|
|
|
|
|
|
|
|
CLOSE vCursor;
|
|
|
|
|
|
|
|
COMMIT;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|