创建两张物化视图。写一个存储过程,包括把两个物化视图手动全部刷新,并把查询结果返回cursor

--创建两张物化视图
--第一张物化视图

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_allcardinfo 
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;

猜你喜欢

转载自blog.csdn.net/qq_40477943/article/details/80625293