我们创建一个定时器,需要先创建一个存储过程,创建完存储过程后,再创建定时器,不能同时执行。
1、创建存储过程
create or replace procedure tenant_job is
begin
insert into t_gd_hd_sys_tenant_act (id,activity_code,user_id,tenant_id,create_datetime,update_datetime)
select t.activity_code,t.activity_code,t.create_tlr_id,'1',t.create_datetime,t.update_datetime from t_gd_wx_activity_info t where t.activity_code not in(select activity_code from t_gd_hd_sys_tenant_act)
and t.create_tlr_id is not null and length(t.create_tlr_id)>15 and t.activity_class='1103';
end;
2、创建定时器
declare
job number;
begin
dbms_job.submit(
job,
'tenant_job;',
sysdate,
'TRUNC(sysdate,''mi'') + 30/(24*60)'
);
commit;
end;
上面的定时器,mi是分钟,记得用四个单引号括起来,可以改为hh小时,那么后面的就改为(24)而不是(24*60)