23 lines
569 B
SQL
23 lines
569 B
SQL
DELIMITER $$
|
|
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 ;
|