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

23 lines
819 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
2024-11-13 08:56:38 +00:00
JOIN vn.shelving sh ON sh.id = 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 ;