create procedure BookID_Generate(in_ISBN char(18),count int,firstID char(10))
begin
while count > 0 do
insert into tblend values(firstID,in_ISBN,'否');
set firstID=firstID+1;
set count=count-1;
end while;
end;
这里in_ISBN, count,firstID三个都是要输入的变量,前面加in同样也报错
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> set firstID=firstID+1;
ERROR 1193 (HY000): Unknown system variable 'firstID'
mysql> set count=count-1;
ERROR 1193 (HY000): Unknown system variable 'count'
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
mysql> end;
你在什么地方执行的?我的脚步是在navicat的查询中执行通过的。
试试下面的:
create procedure BookID_Generate(in_ISBN varchar(18),count int,firstID int)
begin
while count > 0 do
insert into tblend values(firstID,in_ISBN,'否');
set firstID=firstID+1;
set count=count-1;
end while;
end;
可以运行的,你把char类型加个整数1,类型转换错误,就报异常了,存储过程字符用varchar类型的比较多一些。