MySQL函数()不起作用

时间:2014-05-22 18:48:59

标签: mysql

也许有人可以帮助解决此问题:

CREATE FUNCTION inc_btw (prijs DECIMAL(5,2), btw DECIMAL(3,2))
    RETURNS DECIMAL(5,2)
    DETERMINISTIC
    BEGIN
        DECLARE inc_btw DECIMAL(10,2);
        inc_btw = (prijs*(btw+100))/100;
        RETURN inc_btw;
    END;

我觉得这很好,但是我收到了一个错误:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near '' at line 5

3 个答案:

答案 0 :(得分:0)

尝试摆弄你的分隔符:

delimiter $$
CREATE FUNCTION inc_btw (prijs DECIMAL(5,2), btw DECIMAL(3,2))
    RETURNS DECIMAL(5,2)
    DETERMINISTIC
    BEGIN
        DECLARE inc_btw DECIMAL(10,2);
        set inc_btw = (prijs*(btw+100))/100;
        RETURN inc_btw;
    END$$
delimiter;

答案 1 :(得分:0)

尝试这样做(使用delimiter,但set

中缺少inc_btw = (prijs*(btw+100))/100;
DELIMITER $$
CREATE FUNCTION inc_btw (prijs DECIMAL(5,2), btw DECIMAL(3,2))
    RETURNS DECIMAL(5,2)
    DETERMINISTIC
    BEGIN
        DECLARE inc_btw DECIMAL(10,2);
        set inc_btw = (prijs*(btw+100))/100;
        RETURN inc_btw;
    END;
$$
DELIMITER ;

答案 2 :(得分:0)

delimiter $$
CREATE FUNCTION inc_btw (prijs DECIMAL(5,2), btw DECIMAL(3,2))
    RETURNS DECIMAL(5,2)
    DETERMINISTIC
    BEGIN
        DECLARE inc_btw DECIMAL(10,2);
        set inc_btw = (prijs*(btw+100))/100;
        RETURN inc_btw;
    END$$