DELIMITER $$
DROP FUNCTION IF EXISTS `workplantype`.`FUN_STOCKINVENTRY_CHECK` $$
CREATE FUNCTION `workplantype`.`FUN_STOCKINVENTRY_CHECK` (
PONo1 VARCHAR(20),
PartCode1 VARCHAR(45)
) RETURNS bool
BEGIN
DECLARE diff bool;
set diff=false;
select if(Remaining_Quantity=0.00, true, false) as diff from tblstockinventory where PONo=PONo1 && PartCode=PartCode1;
return diff;
END $$
DELIMITER ;
如何避免不允许从函数mysql错误返回结果集?
答案 0 :(得分:3)
select if(Remaining_Quantity=0.00, true, false) into @diff
from tblstockinventory
where PONo=PONo1 AND PartCode=PartCode1;
您可以将IF()缩减为
select Remaining_Quantity=0.00 into @diff
得到相同的结果