ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • ORACLE - Scheduler JOB
    DB/Oracle 2025. 1. 6. 17:57
    반응형

    매일, 17시와 19시에 10분 15분 마다 돌리는 스케쥴 잡 생성 예시

    BEGIN
      SYS.DBMS_SCHEDULER.DROP_JOB
        (job_name  => '스키마.PR_PROC_JOB_NAME');
    END;
    /
    
    BEGIN
      SYS.DBMS_SCHEDULER.CREATE_JOB
        (
           job_name        => '스키마.PR_PROC_JOB_NAME'
          ,start_date      => TO_TIMESTAMP_TZ('2025/01/02 01:30:02.000000 +09:00','yyyy/mm/dd hh24:mi:ss.ff tzh:tzm')
          ,repeat_interval => 'FREQ=DAILY; BYHOUR=17,19; BYMINUTE=10,15'
          ,end_date        => NULL
          ,job_class       => 'DEFAULT_JOB_CLASS'
          ,job_type        => 'PLSQL_BLOCK'
          ,job_action      => 'DECLARE
                                    OUT_VALUE_1 VARCHAR2(100);
                               BEGIN
                                    스키마.PROC_프로시저명(OUT_VALUE_1);
                               END;'
          ,comments        => '프로시저 배치 돌리기'
        );
      SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
        ( name      => '스키마.PR_PROC_JOB_NAME'
         ,attribute => 'RESTARTABLE'
         ,value     => FALSE);
      SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
        ( name      => '스키마.PR_PROC_JOB_NAME'
         ,attribute => 'LOGGING_LEVEL'
         ,value     => SYS.DBMS_SCHEDULER.LOGGING_OFF);
      SYS.DBMS_SCHEDULER.SET_ATTRIBUTE_NULL
        ( name      => '스키마.PR_PROC_JOB_NAME'
         ,attribute => 'MAX_FAILURES');
      SYS.DBMS_SCHEDULER.SET_ATTRIBUTE_NULL
        ( name      => '스키마.PR_PROC_JOB_NAME'
         ,attribute => 'MAX_RUNS');
      SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
        ( name      => '스키마.PR_PROC_JOB_NAME'
         ,attribute => 'STOP_ON_WINDOW_CLOSE'
         ,value     => FALSE);
      SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
        ( name      => '스키마.PR_PROC_JOB_NAME'
         ,attribute => 'JOB_PRIORITY'
         ,value     => 3);
      SYS.DBMS_SCHEDULER.SET_ATTRIBUTE_NULL
        ( name      => '스키마.PR_PROC_JOB_NAME'
         ,attribute => 'SCHEDULE_LIMIT');
      SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
        ( name      => '스키마.PR_PROC_JOB_NAME'
         ,attribute => 'AUTO_DROP'
         ,value     => TRUE);
      SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
        ( name      => '스키마.PR_PROC_JOB_NAME'
         ,attribute => 'RESTART_ON_RECOVERY'
         ,value     => FALSE);
      SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
        ( name      => '스키마.PR_PROC_JOB_NAME'
         ,attribute => 'RESTART_ON_FAILURE'
         ,value     => FALSE);
      SYS.DBMS_SCHEDULER.SET_ATTRIBUTE
        ( name      => '스키마.PR_PROC_JOB_NAME'
         ,attribute => 'STORE_OUTPUT'
         ,value     => TRUE);
    
      SYS.DBMS_SCHEDULER.ENABLE
        (name                  => '스키마.PR_PROC_JOB_NAME');
    END;
    /
    반응형

    'DB > Oracle' 카테고리의 다른 글

    여러 스키마들의 유저 정보 및 DB Link를 제외한 모든 정보 삭제  (0) 2024.11.04
    Oracle DB - expdp / impdp  (0) 2024.08.27
    DB User별 - Session Timeout 설정  (0) 2024.07.17
    RDS - SESSION KILL  (0) 2024.06.11
    Table Space 공간 확인  (0) 2024.01.25

    댓글

Designed by Tistory.