【发布时间】:2019-07-19 22:00:54
【问题描述】:
我正在使用 MySQL,但只要我是初学者,我需要一些帮助来理解和解决这个问题
delimiter ./
create procedure getMesuresBetweenDates (in debut timestamp , in fin timestamp , in nomWaspmote varchar(16) , in nomSensor varchar(16) , out resultat int)
begin
declare compte int;
set compte = NULL;
If debut>=fin then set resultat = -2; end if;
else If Not Exists sensorParser then set resultat = -1 ; end if;
else select @compte=count(*) value, timestamp from sensorParser where id_wasp = nomWaspmote and sensor = nomSensor and timestamp >= debut and timestamp <= fin;
if @compte=0 then set resultat = 0; end if;
else set resultat = @compte;
end ./
这是第一个不起作用的else,当我飞过它时,它告诉“else”在这个位置无效,期待:END
我是法国人,所以我希望我的英语不会太差
感谢 Bart,这是新代码:
delimiter ./
create procedure getMesuresBetweenDates (in debut timestamp , in fin timestamp , in nomWaspmote varchar(16) , in nomSensor varchar(16) , out resultat int)
begin
declare compte int;
set compte = NULL;
If debut>=fin then
set resultat = -2;
else If Not Exists (select * from sensorParser) then
set resultat = -1 ;
else select @compte=count(*) value, timestamp from sensorParser where id_wasp = nomWaspmote and sensor = nomSensor and timestamp >= debut and timestamp <= fin;
if @compte=0 then
set resultat = 0;
else set resultat = @compte;
end if;
end ./
它以某种方式起作用,但现在我遇到了 end 的另一个问题:它告诉我该语句不完整,它需要一个 IF 但我不知道在哪里
【问题讨论】:
标签: mysql stored-procedures mysql-workbench