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;

 

posted @   冰冰影  阅读(773)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示