随机数据存储过程

create or replace procedure DAILY_RANDOM_DATA_NEW is
i number;
v_latitude f_tower.latitude%type;
v_longtitude f_tower.longtitude%type;
cursor c_x is
select distinct latitude,longtitude from f_tower t order by latitude;
begin

  open c_x;
  loop
fetch c_x into v_latitude,v_longtitude;
EXIT WHEN C_X%NOTFOUND ;
  i :=1;
while i<=49 loop

insert into w_facility_regular_forecast(FORECAST_ID,RELEASE_DATE,FORECAST_DATE,LONGTITUDE,LATITUDE,HEIGHT,WEATHER,TEMPERATURE,HUMIDITY,ATMOS_PRESSURE, UA,VA,WIND_DIRECTION,WIND_SPEED,WIND_FORCE, PRECIPITATION,WIND_ANGLE)
select
sequence.nextval,trunc(sysdate,'hh'),trunc(sysdate+(1+i)/24,'hh'),
v_longtitude,v_latitude,'1.00',
decode(trunc(dbms_random.value(1,5)), 1, '晴', 2,'阴', 3,'多云',4,'大雨',5,'雾'),
trunc(dbms_random.value(20,36)),round(dbms_random.value(40,80),1),round(dbms_random.value(950,1050),1),'','',
decode(trunc(dbms_random.value(1,8)), 1, '东', 2,'西', 3,'南',4,'北',5,'东南',6,'东北',7,'西南',8,'西北'),
round(dbms_random.value(0,13),1),trunc(dbms_random.value(0,13)),
'',round(dbms_random.value(0,360),1) from dual;


i :=i+1;
end loop;


  COMMIT;
  END LOOP;
  CLOSE C_X;
end DAILY_RANDOM_DATA_NEW;

猜你喜欢

转载自faithlee.iteye.com/blog/1571137