首页 > 代码库 > oracle job 调用存储过程的使用

oracle job 调用存储过程的使用

-- job

begin
  sys.dbms_scheduler.create_job(job_name            => ‘SSS.P_TRMS_CAR_TASK_JOB‘,
                                job_type            => ‘PLSQL_BLOCK‘,
                                job_action          => ‘BEGIN PROC_TT_TRMS_CAR_TASK; END;‘,
                                start_date          => to_date(‘21-06-2017 00:00:00‘, ‘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            => ‘V9.2  巴枪操作关联车辆‘);
end;
/

begin
  sys.dbms_scheduler.create_job(job_name            => ‘SSS.P_TRMS_AIR_SHORT_JOB‘,
                                job_type            => ‘PLSQL_BLOCK‘,
                                job_action          => ‘BEGIN PROC_TT_TRMS_AIR_SHORT; END;‘,
                                start_date          => to_date(‘21-06-2017 00:00:00‘, ‘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            => ‘V9.2  航空短驳‘);
end;
/
 

-- job 查询

 select owner, job_name, state from dba_scheduler_jobs;
 select * from user_scheduler_jobs WHERE job_name IN(‘P_TRMS_CAR_TASK_JOB‘,‘P_TRMS_AIR_SHORT_JOB‘);
 
 
 
-- job 启用

 begin
 dbms_scheduler.enable(‘P_TRMS_CAR_TASK_JOB‘);
 end;
 /
 
 -- job 运行

 begin
 dbms_scheduler.run_job(‘P_TRMS_CAR_TASK_JOB‘,TRUE); -- true代表同步执行
 end;
 /
 
 -- job 停止(不太好用)

 begin
 dbms_scheduler.stop_job(job_name => ‘P_TRMS_CAR_TASK_JOB‘,force => TRUE);
 end; 

/

 -- job 删除(对停job来说好用)

 begin
 dbms_scheduler.drop_job(job_name => ‘SSS.P_TRMS_CAR_TASK_JOB‘,force => TRUE);)
 end;
 /
 
 -- 删除job
 
 begin 
   dbms_scheduler.drop_job(‘P_TRMS_CAR_TASK_JOB‘);    
 end;
 
  begin 
   dbms_scheduler.drop_job(‘P_TRMS_AIR_SHORT_JOB‘);    
 end;  

  

oracle job 调用存储过程的使用