-- ----------------------------
-- Procedure structure for clear_data
-- ----------------------------
DROP PROCEDURE IF EXISTS `clear_data`;
delimiter ;;
CREATE PROCEDURE `clear_data`()
BEGIN
declare cachtime TIMESTAMP;
DECLARE camid VARCHAR(100) DEFAULT '';
DECLARE count INTEGER DEFAULT 1;
declare i int;
set i = 1;
while i <= 391 do
set @table = CONCAT('inspection_events_',i);
set @sql = CONCAT("SELECT cameraid , count(`cameraid`) AS`count` INTO @out_camid, @out_count FROM ", @table ," GROUP BY cameraid ORDER BY count DESC LIMIT 1 ;");
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
#@count_num 必须加@,
#set count = @out_count; 赋值给输出变量
set count = @out_count;
set camid = @out_camid;
IF(