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

23 lines
569 B
MySQL
Raw Permalink Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`collection_isPacked`(vSelf INT)
RETURNS tinyint(1)
DETERMINISTIC
BEGIN
/**
* Check if collection is packed.
*
* @param vSelf the collection to check
* @return true if the collection is packed
*/
DECLARE vTicketsWithoutExpeditions INT;
SELECT (COUNT(*) > 0) INTO vTicketsWithoutExpeditions
FROM vn.ticketCollection tc
LEFT JOIN vn.expedition e ON e.ticketFk = tc.ticketFk
WHERE tc.collectionFk = vSelf
AND ISNULL(e.id);
RETURN NOT vTicketsWithoutExpeditions;
END$$
DELIMITER ;