正在更新中

mysql 存储过程报错:delimiter

电脑版发表于:2019/3/9 15:49
最近刚学sql,学到了存储过程,每当练习的时候就一直出现问题。
现在记录
CREATE PROCEDURE proc_out(OUT stuid INT)

    begin
    select * from studentinfo where studentid=stuid;
    end

这段存储过程初看没有任何问题,但执行的时候就是报错,说是语法问题。

ERROR 1064 (42000): 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 '' at
line 4

后来请教了百度,
是mysql的DELIMITER 的问题,delimiter是分号;。运行时,如果有一行命令以分号结束,回车后,mysql将会执行该命令。但其实在执行里面的delete的时候,存储过程并没有真的结束,同时检查发现没有end。所以就报语法错误了。

正确的sql是

    delimiter $$

CREATE PROCEDURE proc_out(OUT stuid INT)

    begin
    select * from studentinfo where studentid=stuid;
    end $$
    delimiter ;





---------------------
作者:mixzxu
来源:CSDN
原文:https://blog.csdn.net/mixzxu/article/details/79680727
版权声明:本文为博主原创文章,转载请附上博文链接!



关于TNBLOG
TNBLOG,技术分享。技术交流:群号677373950
ICP备案 :渝ICP备18016597号-1
App store Android
精彩评论
{{item.replyName}}
{{item.content}}
{{item.time}}
{{subpj.replyName}}
@{{subpj.beReplyName}}{{subpj.content}}
{{subpj.time}}
猜你喜欢