开发者

Find out the syntax error in this Stored Procedure

开发者 https://www.devze.com 2023-02-05 09:48 出处:网络
DELIMITER // CREATE PROCEDURE compare (x I开发者_开发问答NT,y INT) RETURNS INT BEGIN DECLARE test INT;
DELIMITER //
CREATE PROCEDURE compare (x I开发者_开发问答NT,  y INT) RETURNS INT
BEGIN
    DECLARE test INT;

    IF x > y 
        THEN SET test = 1;
    ELSEIF y > x
        THEN SET test = -1;
    ELSE SET test = 0;

    END IF;

    RETURN test;
END
//

Can any one show whats the error here? PhpMyAdmin says

#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 'INT BEGIN DECLARE test INT; IF x > y THEN SET test = 1; ELSEIF y >' at line 1


You have to CREATE FUNCTION instead because procedures cannot return anything, only functions can.

0

精彩评论

暂无评论...
验证码 换一张
取 消