mysql存储过程中begin和end之间很简单的语句都报错,什么原因?

_liang_ 2011-02-24 05:44:18
mysql> create procedure p_file_t()
-> begin
-> declare a int
-> set a=1;
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 'int
set a=1' at line 3
mysql> while a<3 do
-> insert into drbd_t(hash,path) values(“abcd123456”, “/192.168.250.100/file”);
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 'while a<3 do
insert into drbd_t(hash,path) values(“abcd123456”, “/192.168.' at line 1
mysql> set a=a+1;
ERROR 1193 (HY000): Unknown system variable 'a'
mysql> end while;
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 'end while' at line 1
...全文
953 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
_liang_ 2011-02-24
  • 打赏
  • 举报
回复
新手就是可怜,原来这么简单,结帖
mysqldbd 2011-02-24
  • 打赏
  • 举报
回复
 delimiter $$
create procedure p_file_t()
begin
declare a int;
set a=1;
loop1:while a<3 do
insert into drbd_t(hash,path) values('abcd123456', '/192.168.250.100/file');
select a;
set a=a+1;
end while loop1;
end $$
wwwwb 2011-02-24
  • 打赏
  • 举报
回复
delimiter $$
create procedure p_file_t()
begin
...
end $$
delimiter ;
_liang_ 2011-02-24
  • 打赏
  • 举报
回复
create procedure p_file_t()
begin
declare a int
set a=1;
while a<3 do
insert into drbd_t(hash,path) values(“abcd123456”, “/192.168.250.100/file”);
set a=a+1;
end while;
end;
mysqldbd 2011-02-24
  • 打赏
  • 举报
回复
[Quote=引用楼主 _liang_ 的回复:]
mysql> create procedure p_file_t()
-> begin
-> declare a int
-> set a=1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server ver……
[/Quote]

把你的所有sql块贴出来,不要带-> 和mysql>的。

56,677

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧