2024-05-09 05:07:10 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION vn.sectorCollection_hasSalesReserved(vSelf INT) RETURNS tinyint(1)
|
2024-05-08 08:59:19 +00:00
|
|
|
DETERMINISTIC
|
|
|
|
BEGIN
|
|
|
|
/**
|
2024-06-11 10:44:25 +00:00
|
|
|
* Devuelve si sectorCollection tiene reservas
|
|
|
|
* @param vSelf Id de sectorCollection
|
|
|
|
*
|
|
|
|
* returns BOOLEAN
|
|
|
|
*/
|
2024-05-08 08:59:19 +00:00
|
|
|
DECLARE vHasSalesReserved BOOLEAN;
|
|
|
|
|
2024-06-11 10:44:25 +00:00
|
|
|
SELECT DISTINCT COUNT(*) INTO vHasSalesReserved
|
|
|
|
FROM sectorCollection sc
|
|
|
|
JOIN sectorCollectionSaleGroup scsg ON sc.id = scsg.sectorCollectionFk
|
|
|
|
JOIN saleGroup sg ON sg.id = scsg.saleGroupFk
|
|
|
|
JOIN saleGroupDetail sgd ON sgd.saleGroupFk = sg.id
|
|
|
|
JOIN sale s ON s.id = sgd.saleFk
|
|
|
|
JOIN itemShelvingSale iss ON iss.saleFk = s.id
|
|
|
|
JOIN saleTracking st ON st.saleFk = s.id
|
2024-05-08 08:59:19 +00:00
|
|
|
WHERE sc.id = vSelf;
|
|
|
|
|
|
|
|
RETURN vHasSalesReserved;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|