CREATE FUNCTION cleanAmount(amount DECIMAL)
RETURNS decimal(30,2)
LANGUAGE SQL
DETERMINISTIC
NO SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
DECLARE res DECIMAL;
SET res=CAST(COALESCE(amount,0.00) AS DECIMAL(30,2));
RETURN res;
END
SELECT cleanAmount('3.456');
返回 3,00。应该是 3,46