首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Mysql错误1064存储过程错误

问Mysql错误1064存储过程错误
EN

Stack Overflow用户
提问于 2018-05-20 05:54:17
回答 1查看 30关注 0票数 2
代码语言:javascript
复制
create function sf_get_empsallist(dname varchar(100))
returns varchar(300)
begin
declare emplist varchar(300) default '';
declare flag int default 0 ;
declare name varchar(100);
declare sal int;
declare c1 cursor  for
select ename,salary from emp join dept
on emp.deptid=dept.deptid
where deptname=dname;
declare continue handler for not found set flag=1;
open c1;
myloop: loop
fetch c1 into name,sal;
if flag=1 then
leave myloop;
end if;
set emplist=concat(emplist,',',name,'-',sal);
end loop;
return(substr(emplist,2));
close c1;
end
$$

我所犯的错误是

错误代码: 1064。您的SQL语法出现了错误;请检查与您的MySQL服务器版本对应的手册,以获得在第4行附近使用的正确语法

我尽力把它解决了,但没能找到。

EN

回答 1

Stack Overflow用户

发布于 2018-05-20 13:05:15

代码语言:javascript
复制
delimiter $$
SET GLOBAL log_bin_trust_function_creators = 1;
create function sf_get_empsallist(dname varchar(100))
returns varchar(300)
begin
declare emplist varchar(300) default '';
declare flag int default 0 ;
declare name varchar(100);
declare sal int;
declare c1 cursor  for
select ename,salary from emp join dept
on emp.deptid=dept.deptid
where deptname=dname;
declare continue handler for not found set flag=1;
open c1;
myloop: loop
fetch c1 into name,sal;
if flag=1 then
leave myloop;
end if;
set emplist=concat(emplist,',',name,'-',sal);
end loop;
return(substr(emplist,2));
close c1;
end
$$
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50432075

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档