开发者社区> 问答> 正文

mysql 存储过程语法报错?报错

-- 用游标版本
delimiter //
create procedure p_sub() 
begin		
	declare mem_num,pro_num,pat_num,a_num,t_num int; -- sub_num是三级科目的总数量, mem_num 是单个科目下的会员数量,pro_num同理
	declare b int default 0;
	declare single_name varchar(20);
	declare cursor_sub cursor for select name from v_temp_sub;-- 创建一个游标,每次只读取一行数据
	DECLARE CONTINUE HANDLER FOR NOT FOUND SET b = 1; -- 判断游标取完的标志
	open cursor_sub; -- 打开光游标
	fetch cursor_sub into single_name;
	while b <> 1 do 
		select count(*) into mem_num from t_subject ts, t_user u where u.major = ts.id and ts.name = single_name; 
		select count(*) into pro_num from t_subject ts, t_user u,t_project tp where tp.user_id = u.id and u.major = ts.id and ts.name = single_name; 
		select count(*) into pat_num from t_subject ts, t_user u,t_patent tp where tp.user_id = u.id and u.major = ts.id and ts.name = single_name; 
		select count(*) into a_num from t_subject ts, t_user u,t_award tp where tp.user_id = u.id and u.major = ts.id and ts.name = single_name; 
		select count(*) into t_num from t_subject ts, t_user u,t_thesis tp where tp.user_id = u.id and u.major = ts.id and ts.name = single_name; 
		update t_subject ts set m_sum = single_mem_num,pro_sum=pro_num,a_sum=a_num,t_sum=t_num,pat_sum=pat_num where ts.sub_num = single_name;
		fetch cursor_sub into single_name;  
	end while;
	close cursor_sub;
end
//
delimiter ;



各位大牛,大哥哥们,小弟有一事相求。

我写了一个 存储过程,里面有一个游标,如第一张图所示, 为什么end哪里要报错  说是语法错误,unpected end , expecting ':' ..请问这是什么错误啊。。谢谢。我查了好久的资料都不明理。

展开
收起
爱吃鱼的程序员 2020-06-14 20:29:20 488 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    第19行最后面多了两个空格去掉空格就行了谢谢。

    那个不是普通的空格字符,用HEX一看就知道了.

    <imgsrc="http://static.oschina.net/uploads/space/2014/1104/145519_33bi_2254295.jpg"alt="">


    谢谢

    2020-06-14 20:29:36
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
搭建电商项目架构连接MySQL 立即下载
搭建4层电商项目架构,实战连接MySQL 立即下载
PolarDB MySQL引擎重磅功能及产品能力盛大发布 立即下载

相关镜像