注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

阿弥陀佛

街树飘影未见尘 潭月潜水了无声 般若观照心空静...

 
 
 

日志

 
 
关于我

一直从事气象预报、服务建模实践应用。 注重气象物理场、实况场、地理信息、本体知识库、分布式气象内容管理系统建立。 对Barnes客观分析, 小波,计算神经网络、信任传播、贝叶斯推理、专家系统、网络本体语言有一定体会。 一直使用Java、Delphi、Prolog、SQL编程。

网易考拉推荐

2014-05-23 对气候表进行了一些初始处理备忘  

2014-05-23 09:31:35|  分类: Oracle |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

问题:
   发现许多站点的气候特征(最大,最小、平均)数据没有更新。
原因:
用语句
 select s.nm, a.section_id,a.create_time, a.hour_id, a.p from vw_ele_statistics a,stations s
 where a.section_id=s.sta and a.create_time=to_date('1904-01-19','YYYY-MM-DD') and a.stat='最大'  and a.p=-9999;
得到:
NM                   SECTION_ID             CREATE_TIME               HOUR_ID                P                     
-------------------- ---------------------- ------------------------- ---------------------- ----------------------
xxx                    xxx                   19-1月 -04                24                     -9999                 
xxx                    xxx                 19-1月 -04                24                     -9999                 
xxx                    xxx                   19-1月 -04                24                     -9999                 
xxx                    xxx                   19-1月 -04                24                     -9999                 
xxx                    xxx                  19-1月 -04                24                     -9999 
这些站点都是一些临时添加使用,以后又没有持续的站点
==============================================================
update ele_statistics set p=-9999 where p is null and stat='最大';
update ele_statistics set t=-9999 where t is null and stat='最大';
update ele_statistics set tmin=-9999 where tmin is null and stat='最大';
update ele_statistics set tmax=-9999 where tmax is null and stat='最大';
update ele_statistics set t0=-9999 where t0 is null and stat='最大';
update ele_statistics set t0min=-9999 where t0min is null and stat='最大';
update ele_statistics set t0max=-9999 where t0max is null and stat='最大';
update ele_statistics set t5=-9999 where t5 is null and stat='最大';
update ele_statistics set t10=-9999 where t10 is null and stat='最大';
update ele_statistics set t15=-9999 where t15 is null and stat='最大';
update ele_statistics set t20=-9999 where t20 is null and stat='最大';
update ele_statistics set t40=-9999 where t40 is null and stat='最大';
update ele_statistics set e=-9999 where e is null and stat='最大';
update ele_statistics set u=-9999 where u is null and stat='最大';
update ele_statistics set umin=-9999 where umin is null and stat='最大';
update ele_statistics set eva=-9999 where eva is null and stat='最大';
update ele_statistics set v=-9999 where v is null and stat='最大';
update ele_statistics set vmin=-9999 where vmin is null and stat='最大';
update ele_statistics set n=-9999 where n is null and stat='最大';
update ele_statistics set nlow=-9999 where nlow is null and stat='最大';
update ele_statistics set r0012=-9999 where r0012 is null and stat='最大';
update ele_statistics set r1200=-9999 where r1200 is null and stat='最大';
update ele_statistics set r2400=-9999 where r2400 is null and stat='最大';
update ele_statistics set r2412=-9999 where r2412 is null and stat='最大';
commit;
update ele_statistics set p=9999 where p is null and stat='最小';
update ele_statistics set t=9999 where t is null and stat='最小';
update ele_statistics set tmin=9999 where tmin is null and stat='最小';
update ele_statistics set tmax=9999 where tmax is null and stat='最小';
update ele_statistics set t0=9999 where t0 is null and stat='最小';
update ele_statistics set t0min=9999 where t0min is null and stat='最小';
update ele_statistics set t0max=9999 where t0max is null and stat='最小';
update ele_statistics set t5=9999 where t5 is null and stat='最小';
update ele_statistics set t10=9999 where t10 is null and stat='最小';
update ele_statistics set t15=9999 where t15 is null and stat='最小';
update ele_statistics set t20=9999 where t20 is null and stat='最小';
update ele_statistics set t40=9999 where t40 is null and stat='最小';
update ele_statistics set e=9999 where e is null and stat='最小';
update ele_statistics set u=9999 where u is null and stat='最小';
update ele_statistics set umin=9999 where umin is null and stat='最小';
update ele_statistics set eva=9999 where eva is null and stat='最小';
update ele_statistics set v=9999 where v is null and stat='最小';
update ele_statistics set vmin=9999 where vmin is null and stat='最小';
update ele_statistics set n=9999 where n is null and stat='最小';
update ele_statistics set nlow=9999 where nlow is null and stat='最小';
update ele_statistics set r0012=9999 where r0012 is null and stat='最小';
update ele_statistics set r1200=9999 where r1200 is null and stat='最小';
update ele_statistics set r2400=9999 where r2400 is null and stat='最小';
update ele_statistics set r2412=9999 where r2412 is null and stat='最小';
commit;


select * from ele_statistics where t is null and stat='最大'
select * from ele_statistics where t is null and stat='最小'

declare
  ct   date := to_date('2014-04-19','YYYY-MM-DD');
  h_id number := 12;
begin
   --ele_hour2day(ct,h_id);
   stat_day_ten_mon(ct,h_id);
end;

先测试一下日期变量
set serveroutput on
declare
  ct   date := to_date('2014-01-09','YYYY-MM-DD');
  h_id number := 12;
  d date;
begin
  for i in 1..365 loop
    select ct+i into d from dual;
    DBMS_OUTPUT.PUT_LINE(d);
  end loop;
end;
------------------------------------------------------------------------------------
使用循环统计
declare
  ct   date := to_date('2014-01-09','YYYY-MM-DD');
  h_id number := 12;
  d date;
begin
   for i in 1..360 loop
     select ct+i into d from dual;
     stat_day_ten_mon(d,h_id);
   end loop;
end;
====================================================================
检验:
select * from vw_ele_statistics where create_time=to_date('1904-01-05','YYYY-MM-DD') and stat='最大'  and p=-9999;
检验结果:
统计更新不起作用。:-(
===================================================================
create or replace
procedure stat_day_ten_mon(ct in date,h_id in number) as
d     number := -1;
dd    date;
begin
  if h_id = 12 then
     d := toD(ct);
     dd := toYYYY_MM_DD(ct);
     --日气候常量统计
     ele_stat_day(ct);
     --旬气候常量统计
     if d=10 or d=20 or dd=last_day(ct) then
       ele_stat_ten(ct);
     end if;
     --月气候常量统计
     if dd=last_day(ct) then
       ele_stat_mon(ct);
     end if;
  end if;
  stat_rain_day_ten_mon(ct,h_id);
end;
  评论这张
 
阅读(352)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017