标签归档:Job

Oracle创建Job命令

–获取时间和序列
create sequence numbincrease_s;
create table machineTime(seq number,mtime date);

–存储过程
create or replace procedure getMachineTime as
begin
  insert into machineTime values (numbincrease_s.nextval,sysdate);
  commit;
end;

–定义jobs调用上述存储过程,为了看出效果一分钟执行一次
declare
  jobs number;
begin
  sys.dbms_job.submit(jobs, 'getMachineTime;', sysdate, 'sysdate+1/1440');
  commit;
end;

–删除Job
/*begin
  –select job from user_jobs;
  sys.dbms_job.remove(108); –job_id
  commit;
end;*/

–select * from dba_jobs;
–select * from all_jobs;
–select * from user_jobs;

–下面是带参数的存储过程的调用
/*begin
  sys.dbms_job.submit(job => :job,
                      what => 'declare s1 varchar2(200); s2 varchar2(200); begin xxx.xxxxxx(s1,s2); end;',
                      next_date => sysdate,
                      interval => 'sysdate+1/1440');
  commit;
end;*/
–调用系统定义的存储过程类似上述方式。