salix/db/routines/vn/procedures/ticketDown_PrintableSelecti...

23 lines
821 B
MySQL
Raw Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketDown_PrintableSelection`(vSectorFk INT)
BEGIN
UPDATE vn.ticketDown td
JOIN
(SELECT DISTINCT t.id
FROM vn.ticket t
JOIN vn.sale s ON s.ticketFk = t.id
JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id
JOIN vn.itemShelving ish ON ish.id = iss.itemShelvingFk
JOIN vn.shelving sh ON sh.code = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
WHERE p.sectorFk = vSectorFk
) sub ON sub.id = td.ticketFk
JOIN vn.ticketDown_SelectionType tdst ON tdst.description = 'FREE'
JOIN vn.ticketDown_SelectionType tdst2 ON tdst2.description = 'SELECTED'
SET td.selected = tdst2.id
WHERE td.selected = tdst.id;
END$$
DELIMITER ;