我正在尝试编写一个mysql函数,从不同的表中获取数据并将其存储到变量中。。但是我得到的错误是,错误1415(0a000):不允许从函数返回结果集
请帮帮我。。。。我的代码如下,
delimiter //
CREATE FUNCTION FUN_test(productId INT,quantity INT) RETURNS DOUBLE
BEGIN
DECLARE discountPer DOUBLE DEFAULT 0;
DECLARE unitPrice DOUBLE;
DECLARE _discountId INT DEFAULT 0;
DECLARE _lowerLimit INT DEFAULT 0;
DECLARE _higherLimit INT DEFAULT 0;
SELECT @unitPrice := `SellingUnitPrice` FROM `TBL_PRODUCT_MASTER` WHERE `Id` = productId;
SELECT @discountPer := discDetail.`DiscountPercentage`, @_discountId := disc.Id, @_lowerLimit := discDetail.LowerLimit, @_higherLimit = discDetail.HigherLimit FROM `TBL_DISCOUNT_DETAIL` AS discDetail , `TBL_DISCOUNT` AS disc, TBL_PRODUCT_DISCOUNT AS prodDisc WHERE disc.`DiscountStartDate` < NOW() AND disc.`DiscountEndDate` > NOW() AND disc.`SchemeType` = 'AMOUNT' AND discDetail.DiscountId = disc.Id AND prodDisc.productId = productId AND prodDisc.discountId = disc.Id AND prodDisc.`IsEnabled` = 1 AND disc.`IsEnabled` = 1 AND (quantity * unitPrice) >= discDetail.LowerLimit and ((quantity * unitPrice) <= discDetail.HigherLimit);
RETURN discountPer;
END//
delimiter ;
1条答案
按热度按时间omjgkv6w1#
请尝试下面的sql。