56,687
社区成员
发帖
与我相关
我的任务
分享
explain select InstantRainValue into tInstantRainValue
from hy_Rain_c left join hy_terminal_t on tmname = terminalid
where rwid = irwid and SingInDateTime > tBeforDateTime and SingInDateTime <= tSingInDateTime
order by SingInDateTime desc limit 1;
CREATE procedure Proc_Weather_Search(bdate datetime,edate datetime,irwid int,deffer int)
BEGIN
declare tBeforDateTime datetime;
declare tInDateTime datetime;
declare tSingInDateTime datetime;
declare tInstantDir int;
declare tInstantSp int;
declare tVisiValue1Min int;
declare tMin1RVR int;
declare tAirtemp numeric(18, 1);
declare tHumity int;
declare tDp numeric(18, 1);
declare tQFE numeric(18, 1);
declare tQNH numeric(18, 1);
declare tInstantRainValue numeric(18, 1);
declare tCloudBase int;
CREATE TEMPORARY TABLE if not exists tmp_Weather_Search(SingInDateTime datetime,InstantDir int,InstantSp int,VisiValue1Min int,Min1RVR int,
Airtemp numeric(18, 1),Humity int,Dp numeric(18, 1),QFE numeric(18, 1),QNH numeric(18, 1),InstantRainValue numeric(18, 1),
CloudBase int ,primary key(SingInDateTime)) ENGINE = MYISAM;
delete from tmp_Weather_Search;
if deffer=1 or deffer=2 then
BEGIN
set tSingInDateTime = bdate;
WHILE(tSingInDateTime <= edate) DO
set tBeforDateTime = ADDDATE(tSingInDateTime, INTERVAL -1 MINUTE);
set tInDateTime = ADDDATE(tSingInDateTime, INTERVAL 1 MINUTE);
set tInstantDir = NULL;
set tInstantSp = NULL;
set tVisiValue1Min = NULL;
set tMin1RVR = NULL;
set tAirtemp = NULL;
set tHumity = NULL;
set tDp = NULL;
set tQFE = NULL;
set tQNH = NULL;
set tInstantRainValue = NULL;
set tCloudBase = NULL;
select InstantDir ,InstantSp into tInstantDir,tInstantSp
from hy_wind_c left join hy_terminal_t on tmname = terminalid
where rwid = irwid and SingInDateTime > tBeforDateTime and SingInDateTime <= tSingInDateTime
order by SingInDateTime desc limit 1;
if tInstantDir IS NULL OR tInstantSp IS NULL then
select InstantDir,InstantSp into tInstantDir,tInstantSp
from hy_wind_c left join hy_terminal_t on tmname = terminalid
where rwid = irwid and SingInDateTime >= tSingInDateTime and SingInDateTime < tInDateTime
order by SingInDateTime limit 1;
end if;
select VisiValue1Min INTO tVisiValue1Min
from hy_visi_c_Mor left join hy_terminal_t on tmname = terminalid
where rwid = irwid and SingInDateTime > tBeforDateTime and SingInDateTime <= tSingInDateTime
order by SingInDateTime desc limit 1;
select Min1RVR into tMin1RVR
from hy_visi_c_Rvr left join hy_terminal_t on tmname = terminalid
where rwid = irwid and SingInDateTime > tBeforDateTime and SingInDateTime <= tSingInDateTime
order by SingInDateTime desc limit 1;
select Airtemp into tAirtemp
from hy_Tmpr_c left join hy_terminal_t on tmname = terminalid
where rwid = irwid and SingInDateTime > tBeforDateTime and SingInDateTime <= tSingInDateTime
order by SingInDateTime desc limit 1;
select Humity into tHumity
from hy_Humi_c left join hy_terminal_t on tmname = terminalid
where rwid = irwid and SingInDateTime > tBeforDateTime and SingInDateTime <= tSingInDateTime
order by SingInDateTime desc limit 1;
select Dp into tDp
from hy_Dp_c left join hy_terminal_t on tmname = terminalid
where rwid = irwid and SingInDateTime > tBeforDateTime and SingInDateTime <= tSingInDateTime
order by SingInDateTime desc limit 1;
select QFE,QNH into tQFE,tQNH
from hy_Pres_c left join hy_terminal_t on tmname = terminalid
where rwid = irwid and SingInDateTime > tBeforDateTime and SingInDateTime <= tSingInDateTime
order by SingInDateTime desc limit 1;
select InstantRainValue into tInstantRainValue
from hy_Rain_c left join hy_terminal_t on tmname = terminalid
where rwid = irwid and SingInDateTime > tBeforDateTime and SingInDateTime <= tSingInDateTime
order by SingInDateTime desc limit 1;
select CloudBase into tCloudBase
from hy_Cloud_c left join hy_terminal_t on tmname = terminalid
where rwid = irwid and SingInDateTime > tBeforDateTime and SingInDateTime <= tSingInDateTime
order by SingInDateTime desc limit 1;
insert into tmp_Weather_Search
values(tSingInDateTime,tInstantDir,tInstantSp,tVisiValue1Min,tMin1RVR,tAirtemp,tHumity,
tDp,tQFE,tQNH,tInstantRainValue,tCloudBase);
set tSingInDateTime = DATE_ADD(tSingInDateTime, interval deffer minute);
END WHILE;
END;
END if;
END//