--1.plsql中学习job
--学习job
--建表
create table test_job(para_date date);
commit;
insert into test_job values(sysdate);
commit;
select * from test_job;
--建立存贮过程
create or replace procedure test_jobproce as
begin
insert into test_job values(sysdate);
end test_jobproce;
--建立job
--建立job后默认是执行的
declare test_job_really number;
begin
dbms_job.submit(test_job_really,'test_jobproce;',sysdate,'sysdate+1/1440');
commit;
end;
---停止job 25是建立的job test_job_really
begin
dbms_job.broken(25,true);
commit;
end;
--启动job
begin
dbms_job.run(25);
commit;
end;
--删除job
begin
dbms_job.remove(25);
commit;
end;
--查看执行结果
select * from test_job order by test_job.para_date desc;
--查看job
select * from sys.user_jobs
--使用下面的SQL查询是否JOB还在Running,前提是需要job执行时间不能过短
select * from dba_jobs_running
--除了submit参数外,其余的几个参数有:
--运行job
dbms_job.run(v_job);
--停止一个job,里面参数true也可是false,next_date(某一时刻停止)也可是sysdate(立刻停止)。
dbms_job.broke(v_job,true,next_date);
--删除某个job
dbms_job.remove(v_job);
dbms_job.what(v_job,'sp_fact_charge_code;');
--修改某个job名 修改下一次运行时间
dbms_job.next_date(v_job,sysdate);
begin
sys.dbms_scheduler.create_job(job_name => 'WJRDL.JOB_JSS_SBK_RYXXSC',
job_type => 'PLSQL_BLOCK',
job_action => 'Declare
o_ret Number;
o_msg Varchar2(200);
Begin
pkg_jss_sbk_ryxxjk.p_Ryxx_Xz_Yb(o_ret, o_msg);
End;',
start_date => to_date('20-12-2014 02:30:00', 'dd-mm-yyyy hh24:mi:ss'),
repeat_interval => 'Freq=Daily;Interval=1',
end_date => to_date('20-12-2014 04:30:00', 'dd-mm-yyyy hh24:mi:ss'),
job_class => 'DEFAULT_JOB_CLASS',
enabled => true,
auto_drop => false,
comments => '江苏省社保卡人员基础数据上传(每天执行1次)');
end;