0
我下面有一段代碼,下面是基於有視圖的某些條件清理表的存儲過程,如果它被刷新,現在請告知,如果我們需要把邏輯循環。如果清理不發生,就應該睡15分鐘,然後重新嘗試,請告知如何做到這一點如何把存儲過程作業睡眠持續35分鐘
create or replace procedure table_clean_up
is
v_refresh_date date;
v_table_count_m integer;
v_table_count_p integer;
begin
select count(*) into v_table_count_m
from all_mviews
where owner = 'M_TO'
and mview_name in ('DC_CASHFLOW_VIEW','DC_CASHFLOW_VIEW_ZERO')
and last_refresh_type = 'COMPLETE';
if v_table_count_m = 2 then
select cast(last_start_date as date) into v_refresh_date
from user_scheduler_jobs
where job_name = 'TABLE_CLEAN_UP_JOB';
select count(*) into v_table_count_p
from all_mviews m
where m.owner = 'P_SM_TO'
and m.mview_name in ('DC_CASHFLOW_VIEW', 'DC_CASHFLOW_VIEW_ZERO')
and m.last_refresh_type = 'COMPLETE'
and m.last_refresh_date > v_refresh_date;
if v_table_count_p = 2 then
delete dc_cashflow_delta;
end if;
end if;
末;
這應該是一個計劃作業,更容易 – kevinsky
你可以使用DBMS_LOCK.SLEEP(秒數) – Jayvee
我在http://stackoverflow.com/questions/39664888/adding-更新了原來的問題例外處理和改進下面存儲的程序和工作或儘管我仍然認爲你應該能夠安排它。 –