salix/db/routines/vn/functions/itemsInSector_get.sql

22 lines
545 B
MySQL
Raw Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`itemsInSector_get`(vTicketFk INT, vSectorFk INT)
RETURNS int(11)
NOT DETERMINISTIC
READS SQL DATA
BEGIN
DECLARE vItemCount INT;
SELECT count(*) INTO vItemCount
FROM vn.sale s
JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk
2024-11-13 08:03:44 +00:00
JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk
WHERE s.ticketFk = vTicketFk
AND p.sectorFk = vSectorFk;
RETURN vItemCount;
END$$
DELIMITER ;