Oracle Job Scheduler example
Recently I helped somebody setup a Job to update some tables from a remote database.
So I thought I would give some example here on how to create and track jobs using the Oracle Job Scheduler
begin
drop table test2;
create table test2 (f1 varchar2(10));
dbms_scheduler.drop_job('JJ');
dbms_scheduler.create_job(
job_name => 'JJ'
,job_type => 'PLSQL_BLOCK'
,job_action => 'begin insert into test2 values(''abc''); end; '
--,job_action => 'null;'
,start_date => systimestamp
,repeat_interval => 'FREQ=MINUTELY; INTERVAL=1'
,enabled => TRUE ,comments => 'Job.');
dbms_scheduler.set_attribute('JJ', 'logging_level', dbms_scheduler.logging_full);
dbms_scheduler.set_attribute('JJ', 'job_priority', 1);
end;
-- Run Job nowbegin dbms_scheduler.run_job('JJ'); end;
select * from user_scheduler_job_log where job_name = 'JJ';
-- Job History
select * from user_scheduler_job_run_details where job_name = 'JJ';
select * from user_scheduler_jobs where job_name = 'JJ'';
-- Jobs that are running now
select * from user_scheduler_running_jobs where job_name = 'JJ';
Troubleshooting Job Scheduler Problems
So I thought I would give some example here on how to create and track jobs using the Oracle Job Scheduler
begin
drop table test2;
create table test2 (f1 varchar2(10));
dbms_scheduler.drop_job('JJ');
dbms_scheduler.create_job(
job_name => 'JJ'
,job_type => 'PLSQL_BLOCK'
,job_action => 'begin insert into test2 values(''abc''); end; '
--,job_action => 'null;'
,start_date => systimestamp
,repeat_interval => 'FREQ=MINUTELY; INTERVAL=1'
,enabled => TRUE ,comments => 'Job.');
dbms_scheduler.set_attribute('JJ', 'logging_level', dbms_scheduler.logging_full);
dbms_scheduler.set_attribute('JJ', 'job_priority', 1);
end;
-- Run Job nowbegin dbms_scheduler.run_job('JJ'); end;
select * from user_scheduler_job_log where job_name = 'JJ';
-- Job History
select * from user_scheduler_job_run_details where job_name = 'JJ';
select * from user_scheduler_jobs where job_name = 'JJ'';
-- Jobs that are running now
select * from user_scheduler_running_jobs where job_name = 'JJ';
Troubleshooting Job Scheduler Problems
Comments