兩個測試數據存儲過程
今日: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;
兩個測試數據存儲過程