我的功能一无所获

时间:2016-11-11 04:42:09

标签: mysql

DELIMITER //
DROP FUNCTION IF EXISTS TotalProductionCost;
CREATE FUNCTION TotalProductionCost(Abuilt int(10),Ucost Decimal(5,2) )
RETURNS Decimal(5,2)
BEGIN
DECLARE TotalCost Decimal(5,2);
SET TotalCost = Abuilt * Ucost; 
RETURN TotalCost;
END //
DELIMITER ;

SELECT TotalProductionCost(10,1000) AS TotalCost;

我在mysql workbench中执行它时创建了上面的函数它执行了很好的查询,但是当我调用函数时,它没有返回任何东西..查询执行得非常好。

1 个答案:

答案 0 :(得分:1)

根据(5,2)的输入和输出,小数的大小会爆炸。

以下作品:

SELECT TotalProductionCost(10,1000.12) AS TotalCost;

试验:

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

所以,是的,我证实你的人很窒息。而且你需要小心你的尺寸和返回。

相关问题