Oracle創建定時任務


1.新建一個存儲過程

create or replace procedure GetInpatients_Test is
begin
for item in (select ttt.dept_admission_to as dept_id,
count(ttt.dept_admission_to) as pat_num
from (select t.patient_id,
t.visit_id,
t.ward_admission_to,
t.admission_date_time,
t.dept_admission_to
from pat_visit t
where t.patient_id not like ('%A%') and t.dept_admission_to is not null) ttt
group by ttt.dept_admission_to) loop
insert into emr_stay_in_hospital (dept_id,dept_num,log_date)
values(item.dept_id,item.pat_num,sysdate);
end loop;
commit;
end GetInpatients_Test;

2.創建定時器

declare
jobno number;
begin
dbms_job.submit(
job=>jobno,
what=>'GetInpatients_Test;',
next_date=>sysdate,
--每十分鍾調用一次
interval=>'interval=>'sysdate+10/(24*60)' );
commit;
end;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM