Thursday, May 21, 2020

Alter Scheduled Jobs

BEGIN
  DBMS_SCHEDULER.SET_ATTRIBUTE('HOURLY_INSERT', 'REPEAT_INTERVAL',
'FREQ=HOURLY;INTERVAL=1');
END;

CREATE TABLE BKUP_TEST
(
  COL1      VARCHAR2(20 BYTE),
  CAP_DATE  TIMESTAMP(6)                        DEFAULT current_timestamp,
  USERNAME  VARCHAR2(10 BYTE)                   DEFAULT user
);



2. Create the procedure
CREATE OR REPLACE PROCEDURE INS_BKPTST
IS
BEGIN
   insert into bkup_test(col1) values('Marines');
  COMMIT;
END;
/

 3




BEGIN
  SYS.DBMS_SCHEDULER.CREATE_JOB
    (
       job_name        => 'SYS.HOURLY_INSERT'
      ,start_date      => TO_TIMESTAMP_TZ('2020/04/30 20:06:43.996546 +08:00','yyyy/mm/dd hh24:mi:ss.ff tzh:tzm')
      ,repeat_interval => 'FREQ=hourly;'
      ,end_date        => NULL
      ,job_class       => 'DEFAULT_JOB_CLASS'
      ,job_type        => 'STORED_PROCEDURE'
      ,job_action      => 'INS_BKPTST'
      ,comments        => NULL
    );
END;
/

SELECT to_char(log_date, 'DD-MON-YY HH24:MI:SS') TIMESTAMP, job_name,
  job_class, operation, status FROM USER_SCHEDULER_JOB_LOG
  WHERE job_name ='HOURLY_INSERT';
 
  select * from  user_scheduler_job_run_details


BEGIN
  DBMS_SCHEDULER.RUN_JOB(
    JOB_NAME            => 'HOURLY_INSERT',
    USE_CURRENT_SESSION => FALSE);
END;
/

SELECT JOB_NAME, STATE FROM DBA_SCHEDULER_JOBS where job_name ='HOURLY_INSERT';

select job_name, owner, enabled from dba_scheduler_jobs where job_name ='HOURLY_INSERT';

exec dbms_scheduler.enable('HOURLY_INSERT');


select * from user_scheduler_job_run_details where job_name ='HOURLY_INSERT';


BEGIN
  DBMS_SCHEDULER.SET_ATTRIBUTE('HOURLY_INSERT', 'REPEAT_INTERVAL',
'FREQ=HOURLY;INTERVAL=1');
END;

select * from user_SCHEDULER_SCHEDULES where job_name ='HOURLY_INSERT';


No comments:

Post a Comment