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