码迷,mamicode.com
首页 > 数据库 > 详细

Oracle Job的批量删除与重建脚本

时间:2018-11-08 14:21:01      阅读:683      评论:0      收藏:0      [点我收藏+]

标签:loop   star   interval   force   清单   个数   ora   数据   obs   

-- 批量删除job  
declare
v_exist number(2); -- job是否存在
begin
  for x in 1..8 LOOP
    select count(1) into v_exist from user_scheduler_jobs WHERE job_name = ‘PROCESS_BILL_DATA_‘ || x ;
    if v_exist > 0 then
      dbms_scheduler.drop_job(job_name => ‘PROCESS_BILL_DATA_‘ || x,force => TRUE);
      dbms_output.put_line(‘drop job :‘ || x );
    end if;
  end loop;
end;
/
-- 查看pl/sql output页签输出,显示日志,删除job的个数


-- 批量创建job  8个
declare
begin
  for x in 1..8 LOOP
      sys.dbms_scheduler.create_job(job_name            => ‘PROCESS_BILL_DATA_‘ || x,
                                    job_type            => ‘PLSQL_BLOCK‘,
                                    job_action          => ‘begin process_bill_data(8,‘||(x-1)||‘,10000,500); end;‘,
                                    start_date          => to_date(‘06-08-2013 16:26:05‘, ‘dd-mm-yyyy hh24:mi:ss‘),
                                    repeat_interval     => ‘FREQ=MINUTELY;INTERVAL=1;‘,
                                    end_date            => to_date(null),
                                    job_class           => ‘DEFAULT_JOB_CLASS‘,
                                    enabled             => true,
                                    auto_drop           => true,
                                    comments            => ‘清单数据处理_‘||x);
      dbms_output.put_line(‘create job :‘ || x );
  end loop;
end;
/

  

Oracle Job的批量删除与重建脚本

标签:loop   star   interval   force   清单   个数   ora   数据   obs   

原文地址:https://www.cnblogs.com/fubinhnust/p/9928642.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!