存储过程
我在phpMyadmin中创建了一个存储过程CREATE PROCEDURE stu_score(IN XH CHAR(10),IN KCH CHAR(15),IN KCScore INTEGER,IN CJ INTEGER,IN XF INTEGER)
BEGIN
IF CJ<60 THEN
UPDATE xs_kc SET Score=KCScore,Credit=0 WHERE StuNumber=XH AND CourseId=KCH;
ELSE IF CJ>60 THEN
UPDATE xs_kc SET Score=KCScore,Credit=XF WHERE StuNumber=XH AND CourseId=KCH;
ELSE
UPDATE xs_kc SET Score=KCScore WHERE StuNumber=XH AND CourseId=KCH;
END IF;
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 4
这是什么原因,请高人指点
------解决方案--------------------到MYSQL命令行工具下试下,应该是你的DELIMITER没有设置。
delimiter //
CREATE PROCEDURE stu_score(IN XH CHAR(10),IN KCH CHAR(15),IN KCScore INTEGER,IN CJ INTEGER,IN XF INTEGER)
BEGIN
IF CJ<60 THEN
UPDATE xs_kc SET Score=KCScore,Credit=0 WHERE StuNumber=XH AND CourseId=KCH;
ELSE IF CJ>60 THEN
UPDATE xs_kc SET Score=KCScore,Credit=XF WHERE StuNumber=XH AND CourseId=KCH;
ELSE
UPDATE xs_kc SET Score=KCScore WHERE StuNumber=XH AND CourseId=KCH;
END IF;
END
//
------解决方案--------------------elseif
不是else if