· 开发文档

· 支付社区

首页

小新支付

文档中心

支付社区

关于我们

init.sql文件中包含存储过程的正确导入方式

未结 分享 1 2069
terrfly
terrfly 2019-11-07 14:26:02
悬赏:20 收藏
如果在init.sql 中包含存储过程并且存储过程包含查询语句,如下: [pre] drop procedure if exists proc_s_test; create procedure proc_s_test(in aid INT) BEGIN select 1 from dual; END; [/pre] 直接通过 mysql 导入 [pre] mysql> source init.sql; [/pre] 会提示异常信息: [pre] 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 WHILE' [/pre] 原因是: mysql命令行 默认按照 【;】符号为提交,故执行到第4行 进行提交操作时认为sql有误,导致执行失败! 修改后的脚本为: [pre] -- 设置提交换行符为 ; delimiter ; drop procedure if exists proc_s_test; -- 设置提交换行符为 // delimiter // create procedure proc_s_test(in aid INT) BEGIN select 1 from dual; END// -- 设置提交换行符为 ; delimiter ; [/pre] 这样就不会报错啦!face[微笑]
回帖
  • 大森林 (管理员)
    2019-11-07 15:30:29
    face[赞] 很好
    0 回复
本周热议