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.
精彩评论