tags:

views:

20

answers:

1
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 ;

how ro avoid the not allowed to return a result set from a function mysql error?

+1  A: 
select if(Remaining_Quantity=0.00, true, false) into @diff 
from tblstockinventory 
where PONo=PONo1 AND PartCode=PartCode1;

You can reduce IF() to

select Remaining_Quantity=0.00 into @diff 

And get the same result

Naktibalda
+1 You beat me to it by seconds. Note that `@diff` needs to be just `diff`, as it's a declared variable.
Mike