23 lines
571 B
MySQL
23 lines
571 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`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 ;
|