Friday, October 16, 2015

Oracle jobs creation and logging activation

create job , configure logging and enable it:

BEGIN
DBMS_SCHEDULER.CREATE_JOB (
   job_name           =>  'TEST_SCHEDULED_JOB',
   job_type           =>  'PLSQL_BLOCK',
   job_action         =>  'BEGIN select * from  myschema.mytable; END;',
   start_date         =>  TO_DATE('14/01/2015,12:00 AM', 'DD/MM/YYYY,HH:MI AM'),
   repeat_interval    =>  'FREQ=HOURLY; INTERVAL=4',
   end_date           =>  null,
   job_class          =>  'DEFAULT_JOB_CLASS',
   comments           =>  'detection and notification of ORA- errors in log files.  Notify admins');
END;
/

BEGIN
DBMS_SCHEDULER.SET_ATTRIBUTE ('TEST_SCHEDULED_JOB', 'logging_level', DBMS_SCHEDULER.LOGGING_FULL);
END;
/

BEGIN
DBMS_SCHEDULER.ENABLE('TEST_SCHEDULED_JOB');
END;
/

Check that job scheduled correctly:

select last_start_date, next_run_date 
from DBA_SCHEDULER_JOBS
where job_name = 'BOD_CHANGE_SYSDATE' ; 


after testing drop a job :

begin
 DBMS_SCHEDULER.drop_job (job_name => 'TEST_SCHEDULED_JOB');
end;
/

No comments:

Post a Comment