首页 | 新闻 | 交流 | 问吧 | 文档 | 手册 | 下载 | 博客

收藏此问题 发表新评论

MySQL存储过程求助

下面这段代码没有提示错误:
复制内容到剪贴板
代码:
DROP PROCEDURE IF EXISTS simpleprocc1;
delimiter //
CREATE PROCEDURE simpleprocc1 (IN v INT)
BEGIN
DECLARE param1 INT;
SET @id = v ;
SELECT rank INTO param1 FROM jr_test2 WHERE id=@id;
DELETE FROM jr_test2 WHERE id=@id;
IF param1=1 THEN
UPDATE jr_test2 SET rank=rank-1;
ELSE
UPDATE jr_test2 SET rank=rank-1 WHERE rank>param1;
END IF;
END
[ 本帖最后由 woodychenzhuo 于 2008-7-25 16:48 编辑 ]
昵称: woodychenzhuo  时间: 2008-07-25 16:16:00
而下面这段代码就有错误了,只是最下面多了一行代码而已,错在哪里了,求助!
复制内容到剪贴板
代码:
DROP PROCEDURE IF EXISTS simpleprocc1;
delimiter //
CREATE PROCEDURE simpleprocc1 (IN v INT)
BEGIN
DECLARE param1 INT;
SET @id = v ;
SELECT rank INTO param1 FROM jr_test2 WHERE id=@id;
DELETE FROM jr_test2 WHERE id=@id;
IF param1=1 THEN
UPDATE jr_test2 SET rank=rank-1;
ELSE
UPDATE jr_test2 SET rank=rank-1 WHERE rank>param1;
END IF;
END
CALL simpleprocc1(12);
昵称: woodychenzhuo  时间: 2008-07-25 16:17:00
END;//这里少了分号
CALL simpleprocc1(12);
昵称: coolstr  时间: 2008-07-25 17:35:00