Mysql中,这个存储过程有什么语法错误??
一个apptest表,有3个字段,时间,速度和id号,我想用id号来作为循环条件,用下一个时间减去上一个时间,再乘以速度,得到路程createprocedureprot1...
一个apptest表,有3个字段,时间,速度和id号,我想用id号来作为循环条件,用下一个时间减去上一个时间,再乘以速度,得到路程
create procedure prot1(out energy int)
begin
declare v1 int;
declare v2 int;
declare v3 int;
declare v4 int;
declare n int;
set n=1;
while n<5 do
select sample_time into v1 from apptest where id=n;
select sample_time into v2 from apptest where id=n+1;
set v3=v2-v1;
select speed into v4 from apptest where id=n;
energy=v4*v3;
select energy;
set n=n+1;
end while;
end 展开
create procedure prot1(out energy int)
begin
declare v1 int;
declare v2 int;
declare v3 int;
declare v4 int;
declare n int;
set n=1;
while n<5 do
select sample_time into v1 from apptest where id=n;
select sample_time into v2 from apptest where id=n+1;
set v3=v2-v1;
select speed into v4 from apptest where id=n;
energy=v4*v3;
select energy;
set n=n+1;
end while;
end 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询