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判断根本没有错误呀。
end if
差个分号