SELECT * FROM DBA_SCHEDULER_JOBS t WHERE OWNER='TEST';
SELECT * FROM DBA_SCHEDULER_PROGRAMS WHERE OWNER='TEST';
--1.stop jobs and enable/disable jobs
BEGIN
FOR V IN(SELECT * FROM DBA_SCHEDULER_JOBS T WHERE OWNER='TEST' AND T.ENABLED='TRUE' AND STATE IN('RUNNING'))
LOOP
DBMS_SCHEDULER.STOP_JOB(V.JOB_NAME);
DBMS_SCHEDULER.DISABLE(V.JOB_NAME);
COMMIT;
END LOOP;
END;
/
--2.enable/disable jobs
SELECT * FROM DBA_SCHEDULER_JOBS t WHERE OWNER='TEST' and t.enabled='TRUE';
SELECT * FROM DBA_SCHEDULER_PROGRAMS WHERE OWNER='TEST';
BEGIN
FOR V IN(SELECT * FROM DBA_SCHEDULER_JOBS T WHERE OWNER='TEST' AND T.ENABLED='TRUE' AND STATE NOT IN('RUNNING'))
LOOP
DBMS_SCHEDULER.DISABLE(V.JOB_NAME);
COMMIT;
END LOOP;
END;
/
--3.drop jobs and programs
--clear data
BEGIN
--execute immediate 'TRUNCATE TABLE WF_NODE_TIMELINE';
--execute immediate 'TRUNCATE TABLE WF_PROCESS';
--execute immediate 'truncate table WF_NODE_QUEUE';
FOR V IN (SELECT * FROM USER_SCHEDULER_JOBS WHERE JOB_NAME LIKE 'JOB_%') LOOP
DBMS_SCHEDULER.DROP_JOB(V.JOB_NAME);
END LOOP;
FOR V IN (SELECT *
FROM USER_SCHEDULER_PROGRAMS
WHERE PROGRAM_NAME LIKE 'PRO_%') LOOP
DBMS_SCHEDULER.DROP_PROGRAM(V.PROGRAM_NAME);
END LOOP;
END;
/
--4.SET ATTRIBUTE
BEGIN
DBMS_SCHEDULER.SET_ATTRIBUTE (
name => 'JOB_ODS_IN_ACQ_APPL_PROD_MASTE',
attribute => 'repeat_interval',
value => 'freq=weekly; byday=wed');
END;
/
----------ONE RUN THEN DROP
BEGIN
DBMS_SCHEDULER.CREATE_JOB
(
job_name =>'TEST',
job_type =>'PLSQL_BLOCK',
job_action =>'PROC_EXEC;',
job_class =>'DEFAULT_JOB_CLASS',
enabled =>TRUE,
auto_drop =>TRUE,
comments =>''
);
END;