salix/db/routines/vn/functions/entry_isInventoryOrPrevious...

19 lines
460 B
SQL

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`entry_isInventoryOrPrevious`(vSelf INT)
RETURNS int(11)
DETERMINISTIC
BEGIN
DECLARE vIsInventoryOrPrevious BOOL;
SELECT ec.inventorySupplierFk = e.supplierFk OR t.landed < c.inventoried
INTO vIsInventoryOrPrevious
FROM entry e
JOIN travel t ON e.travelFk = t.id
JOIN entryConfig ec
JOIN config c
WHERE e.id = vSelf;
RETURN vIsInventoryOrPrevious;
END$$
DELIMITER ;