Fetch Next From rs Into result;
INSERT INTO `xxxxxxxxx`.`xxxxx` (`dtuid`, `date_time`, `xxxxxxxxx`, `xxxxx`, `xxxxxxx`, `xxxxx`, `xxxxx`, `xxxx`, `xxxxx`, `xxx`, `v_outxxxxx_2`, `xxxx`, `xxxxxx`, `a_run_3`, `v_out_3`, `tem_3`, `speed_4`, `a_run_4`, `v_out_4`, `tem_4`, `all_v`, `all_a`, `all_active_power`, `all_reactive_power`, `all_apparent_power`, `pumg_station_tem`, `pumg_station_hum`, `bearing_tem_front_1`, `bearing_tem__back_1`, `coil_tem_1`, `bearing_tem_front_2`, `bearing_tem__back_2`, `coil_tem_2`, `bearing_tem_front_3`, `bearing_tem__back_3`, `coil_tem_3`, `bearing_tem_front_4`, `bearing_tem__back_4`, `coil_tem_4`, `ph`, `chlorine`, `turbidity`, `all_power`, `month_power`, `int_flow`, `oud_flow`) VALUES (result, DATE_FORMAT(now(),'%Y-%m-%d'), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
set sqlr=CONCAT("UPDATE `xxxxxxx`.`xxxxxx` SET `xxxxx`=(SELECT avg(xxxx) as int_water_press FROM xxxx",xxxx," where xxxxxx LIKE '",DATE_FORMAT(now(),'%Y-%m-%d'),"%' and xxxxxx<>-9999 and int_water_press<>9999 ) where xxxxxxx like '",DATE_FORMAT(now(),'%Y-%m-%d'),"%' and xxxxxx= ",result);
set @sqlr=sqlr;
prepare stmt from @sqlr;
execute stmt;
deallocate prepare stmt;
UNTIL Done
END REPEAT;
END
BEGIN
DECLARE Done INT DEFAULT 0;
DECLARE result VARCHAR (16);
DECLARE sqlr VARCHAR (2048);
DECLARE sqlre VARCHAR (2048);
DECLARE rs CURSOR FOR SELECT
stations.DTU
FROM
`stations`
WHERE
`Status` > 0;
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET Done = 1;
OPEN rs;
REPEAT
FETCH Next
FROM
rs INTO result;
SET sqlr = CONCAT(
"select",@pumg_run_time_1,":=pumg_run_time_1,",@pumg_run_time_2,":=pumg_run_time_2,",@pumg_run_time_3,":=pumg_run_time_3,",@pumg_run_time_4,":=pumg_run_time_4 from wd",result," where date_time like '",DATE_FORMAT(now(),'%Y-%m-%d'),"%' order by date_time limit 1;"
"select",@pumg_run_time_1e,":=pumg_run_time_1,",@pumg_run_time_2e,":=pumg_run_time_2,",@pumg_run_time_3e,":=pumg_run_time_3,",@pumg_run_time_4e,":=pumg_run_time_4 from wd",result," where date_time like '",DATE_FORMAT(now(),'%Y-%m-%d'),"%' order by date_time desc limit 1;"
);
标签: 杂谈 |