建立兩張物化檢視。寫一個儲存過程,包括把兩個物化檢視手動全部重新整理,並把查詢結果返回cursor
阿新 • • 發佈:2019-02-19
--建立兩張物化檢視
--第一張物化檢視
create materialized view mv_ref_user_phone_all
as select * from v_ref_user_phone_all;
--第二張物化檢視
create materialized view mv_verify_userinfo_d_all
as select * from v_verify_userinfo_d_all;
return sys_refcursor
is
cur_all_user sys_refcursor;
begin
--兩個物化檢視的全部重新整理
dbms_mview.refresh('mv_ref_user_phone_all','c');
dbms_mview.refresh('mv_verify_userinfo_d_all,'c');
--遊標
open cur_all_user for
'select a.user_id,MOBILE,CARDTYPE,CARDNO,b.LASTUPD_DTIM
from mv_ref_user_phone_all a
jion mv_verify_userinfo_d_all b
on a.user_id = b.user_id
where b.LASTUPD_DTIM > trunc(sysdate - 1)';
return cur_all_user;
end fun_get_allcardinfo;
--第一張物化檢視
create materialized view mv_ref_user_phone_all
as select * from v_ref_user_phone_all;
--第二張物化檢視
create materialized view mv_verify_userinfo_d_all
as select * from v_verify_userinfo_d_all;
--儲存過程
--兩個物化檢視的全部重新整理,和,把查詢結果返回cursor
create or replace function fun_get_allcardinforeturn sys_refcursor
is
cur_all_user sys_refcursor;
begin
--兩個物化檢視的全部重新整理
dbms_mview.refresh('mv_ref_user_phone_all','c');
dbms_mview.refresh('mv_verify_userinfo_d_all,'c');
--遊標
open cur_all_user for
'select a.user_id,MOBILE,CARDTYPE,CARDNO,b.LASTUPD_DTIM
from mv_ref_user_phone_all a
jion mv_verify_userinfo_d_all b
on a.user_id = b.user_id
where b.LASTUPD_DTIM > trunc(sysdate - 1)';
return cur_all_user;
end fun_get_allcardinfo;