Mysql的存储过程真的是个坑!求助下面的存储过程哪里错啦,实在是找不到哪里的问题了。
BEGIN
declare step1,step2 varchar(50);
declare p_tar_code varchar(10);
DECLARE p_tYear,p_period int;
DECLARE p_centAll,p_up_comCent decimal(5,2);
-- 1:获取当前年度和季度
select period,tyear into p_period,p_tYear from tm_checkmain where id = 95 LIMIT 1;
-- 2:如果季度是1,则上年得分为0,否则要计算
if period = 21 then
set p_up_comCent = 0;
end if
select tar_code into p_tar_code from tm_checkdetails where id = 95 LIMIT 1;
set str = p_tar_code;
END
将IF判断注释掉,则通过,否则则报错。
One or more errors have occurred while processing your request:
下列查询失败了: "CREATE DEFINER=root
@localhost
PROCEDURE comCent
(IN cm_id
INT(11) UNSIGNED, OUT str
VARCHAR(10)) NO SQL SQL SECURITY DEFINER BEGIN declare step1,step2 varchar(50); declare p_tar_code varchar(10); DECLARE p_tYear,p_period int; DECLARE p_centAll,p_up_comCent decimal(5,2); -- 1:获取当前年度和季度 select period,tyear into p_period,p_tYear from tm_checkmain where id = 95 LIMIT 1; -- 2:如果季度是1,则上年得分为0,否则要计算 if period = 21 then set p_up_comCent = 0; end if -- select tar_code into p_tar_code from tm_checkdetails where id = 95 LIMIT 1; -- set step2 = '如果是月则返回'; -- set str = p_tar_code; END"
MySQL 返回: #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 'END' at line 22
请教高手,IF判断根本没有错误呀。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
end if
差个分号