mysql 版本5.7.13 windows下面运行
本人的代码:create table nums(a int unsigned not null primary key) engine=innodb;(运行不出错)
create peocedure pcreatenums (cnt int unsigned)
begin
declare s int unsigned default 1;(始终是说本人的1后面少了分号,但是本人的输入法一直对的,也一直加了分号,运行一直出错怎么办)
小白刚学习不久,求指导答。已经出现第二次这种情况,网上也没找到和本人一样的问题的人。
本人的代码:create table nums(a int unsigned not null primary key) engine=innodb;(运行不出错)
create peocedure pcreatenums (cnt int unsigned)
begin
declare s int unsigned default 1;(始终是说本人的1后面少了分号,但是本人的输入法一直对的,也一直加了分号,运行一直出错怎么办)
小白刚学习不久,求指导答。已经出现第二次这种情况,网上也没找到和本人一样的问题的人。
解决方案
15
DELIMITER $$
create table nums(a int unsigned not null primary key) engine=innodb;(运行不出错)
create peocedure pcreatenums (cnt int unsigned)
begin
declare s int unsigned default 1;
..
…
ene$$
DELIMITER ;
create table nums(a int unsigned not null primary key) engine=innodb;(运行不出错)
create peocedure pcreatenums (cnt int unsigned)
begin
declare s int unsigned default 1;
..
…
ene$$
DELIMITER ;
10
mysql 中的存储过程是这样的:
mysql> delimiter $$ mysql> create procedure clean() -> modifies sql data -> begin -> delete from t1; -> end$$ Query OK, 0 rows affected (0.20 sec) mysql> delimiter ; mysql> call clean(); Query OK, 1 row affected (0.20 sec)
15
你没定义别名,默认取表达式前的字符串,如 :定义Col
drop procedure if exists pgetworkdays6; delimiter $$ create procedure pgetworkdays6(s datetime,e datetime) begin select floor (days/7)*5 +days%7 -case when 6 between wd and wd+days/7 - 1 then 1 else 0 end -case when 7 between wd and wd+days/7 - 1 then 1 else 0 end as Col from (select datediff(e,s)+1 as days,weekday(s)+1 as wd) as a; end $$ delimiter ; call pgetworkdays6 ("2005-01-01","2005-12-31") ;