标签:date type 存储 run val sql 用户 oop 传递
今日:V_TYPES = 1
昨日:V_TYPES = 2
一周:V_TYPES = 3
------------------------------------ //注释里的数字根据实际情况,之前的数字
create or replace PROCEDURE "PD_TEST_YANJING2" (V_TYPES in varchar2, cursor_a out sys_refcursor)
as
/* 编写人:YANJING ,FOR TESTING
*/
V_DATE1 DATE;
V_DATE2 DATE;
v_guid varchar(50);
begin
SELECT SYS_GUID() into v_guid FROM DUAL; --获得当前用户guid
if V_TYPES = ‘1‘ then -- 如果时间类型是1, 在临时表中插入15分钟粒度的数据。
SELECT trunc(SYSDATE),trunc(sysdate,‘hh24‘) into V_DATE1,V_DATE2 FROM DUAL;
loop
exit when V_DATE1 >= V_DATE2; --时间轴传递的结束时间往前推一个粒度作为结束时间
insert into temp_time_list(stat_time,guid) values(V_DATE1,v_guid);
V_DATE1 := V_DATE1 + 1/24;
end loop;
elsif V_TYPES = ‘2‘ then -- 如果时间类型是2, 在临时表中插入60分钟粒度的数据。
SELECT trunc(SYSDATE)-1,trunc(sysdate) into V_DATE1,V_DATE2 FROM DUAL;
loop
exit when V_DATE1 >= V_DATE2; --时间轴传递的结束时间往前推一个粒度作为结束时间
insert into temp_time_list(stat_time,guid) values(V_DATE1,v_guid);
V_DATE1 := V_DATE1 + 1/24;
end loop;
else -- 如果时间类型是3, 在临时表中插入天时间粒度的数据。
SELECT trunc(SYSDATE)-7,trunc(sysdate) into V_DATE1,V_DATE2 FROM DUAL;
loop
exit when V_DATE1 >= V_DATE2; --时间轴传递的结束时间往前推一个粒度作为结束时间
insert into temp_time_list(stat_time,guid) values(V_DATE1,v_guid);
V_DATE1 := V_DATE1 + 1;
end loop;
end if;
if V_TYPES = ‘1‘ then -- 查询15分钟表,查询全部数据,全互联单位。
open cursor_a for
select to_char(t.stat_time,‘hh24:mi‘) as name, round(dbms_random.value *100,0) as value ,‘正面‘ as category
from temp_time_list t
where t.guid = v_guid
union all
select to_char(t.stat_time,‘hh24:mi‘) as name, round(dbms_random.value *100,0) as value ,‘中立‘ as category
from temp_time_list t
where t.guid = v_guid
union all
select to_char(t.stat_time,‘hh24:mi‘) as name, round(dbms_random.value *100,0) as value ,‘负面‘ as category
from temp_time_list t
where t.guid = v_guid;
elsif V_TYPES = ‘2‘ then -- 查询60分钟表,查询全部数据, 具体的互联单位。 sql 中 拼接运营商 ,但是不拼接 is_wireless_flag。
open cursor_a for
select to_char(t.stat_time,‘hh24:mi‘) as name, round(dbms_random.value *100,0) as value ,‘正面‘ as category
from temp_time_list t
where t.guid = v_guid
union all
select to_char(t.stat_time,‘hh24:mi‘) as name, round(dbms_random.value *100,0) as value ,‘中立‘ as category
from temp_time_list t
where t.guid = v_guid
union all
select to_char(t.stat_time,‘hh24:mi‘) as name, round(dbms_random.value *100,0) as value ,‘负面‘ as category
from temp_time_list t
where t.guid = v_guid;
else -- 查询24小时表,查询全部数据, 具体的互联单位。 sql 中 拼接运营商 ,但是不拼接 is_wireless_flag。
open cursor_a for
select to_char(t.stat_time,‘MM-DD‘) as name, round(dbms_random.value *100,0) as value ,‘正面‘ as category
from temp_time_list t
where t.guid = v_guid
union all
select to_char(t.stat_time,‘MM-DD‘) as name, round(dbms_random.value *100,0) as value ,‘中立‘ as category
from temp_time_list t
where t.guid = v_guid
union all
select to_char(t.stat_time,‘MM-DD‘) as name, round(dbms_random.value *100,0) as value ,‘负面‘ as category
from temp_time_list t
where t.guid = v_guid;
end if; -- 结束
end;
--------------------------------------------------
create or replace PROCEDURE "PD_TEST_YANJING" (V_TYPES in varchar2, cursor_a out sys_refcursor)
as
/* 编写人:YANJING ,FOR TESTING
*/
V_DATE1 DATE;
V_DATE2 DATE;
v_guid varchar(50);
begin
SELECT SYS_GUID() into v_guid FROM DUAL; --获得当前用户guid
if V_TYPES = ‘1‘ then -- 如果时间类型是1, 在临时表中插入15分钟粒度的数据。
SELECT trunc(SYSDATE),trunc(sysdate,‘hh24‘) into V_DATE1,V_DATE2 FROM DUAL;
loop
exit when V_DATE1 >= V_DATE2; --时间轴传递的结束时间往前推一个粒度作为结束时间
insert into temp_time_list(stat_time,guid) values(V_DATE1,v_guid);
V_DATE1 := V_DATE1 + 1/24;
end loop;
elsif V_TYPES = ‘2‘ then -- 如果时间类型是2, 在临时表中插入60分钟粒度的数据。
SELECT trunc(SYSDATE)-1,trunc(sysdate) into V_DATE1,V_DATE2 FROM DUAL;
loop
exit when V_DATE1 >= V_DATE2; --时间轴传递的结束时间往前推一个粒度作为结束时间
insert into temp_time_list(stat_time,guid) values(V_DATE1,v_guid);
V_DATE1 := V_DATE1 + 1/24;
end loop;
else -- 如果时间类型是3, 在临时表中插入天时间粒度的数据。
SELECT trunc(SYSDATE)-7,trunc(sysdate) into V_DATE1,V_DATE2 FROM DUAL;
loop
exit when V_DATE1 >= V_DATE2; --时间轴传递的结束时间往前推一个粒度作为结束时间
insert into temp_time_list(stat_time,guid) values(V_DATE1,v_guid);
V_DATE1 := V_DATE1 + 1;
end loop;
end if;
if V_TYPES = ‘1‘ then -- 查询15分钟表,查询全部数据,全互联单位。
open cursor_a for
select to_char(t.stat_time,‘hh24:mi‘) as name, round(dbms_random.value *100,0) as value ,‘网站‘ as category
from temp_time_list t
where t.guid = v_guid
union all
select to_char(t.stat_time,‘hh24:mi‘) as name, round(dbms_random.value *100,0) as value ,‘论坛‘ as category
from temp_time_list t
where t.guid = v_guid;
elsif V_TYPES = ‘2‘ then -- 查询60分钟表,查询全部数据, 具体的互联单位。 sql 中 拼接运营商 ,但是不拼接 is_wireless_flag。
open cursor_a for
select to_char(t.stat_time,‘hh24:mi‘) as name, round(dbms_random.value *100,0) as value ,‘网站‘ as category
from temp_time_list t
where t.guid = v_guid
union all
select to_char(t.stat_time,‘hh24:mi‘) as name, round(dbms_random.value *100,0) as value ,‘论坛‘ as category
from temp_time_list t
where t.guid = v_guid;
else -- 查询24小时表,查询全部数据, 具体的互联单位。 sql 中 拼接运营商 ,但是不拼接 is_wireless_flag。
open cursor_a for
select to_char(t.stat_time,‘MM-DD‘) as name, round(dbms_random.value *100,0) as value ,‘网站‘ as category
from temp_time_list t
where t.guid = v_guid
union all
select to_char(t.stat_time,‘MM-DD‘) as name, round(dbms_random.value *100,0) as value ,‘论坛‘ as category
from temp_time_list t
where t.guid = v_guid;
end if; -- 结束
end;
标签:date type 存储 run val sql 用户 oop 传递
原文地址:http://www.cnblogs.com/dayuyanwei/p/6907525.html