2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`collection_isPacked`(vSelf INT)
|
2024-01-15 11:31:03 +00:00
|
|
|
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 ;
|