1 Reply Latest reply: May 14, 2012 11:30 AM by spajdy RSS

    Job event and chain

    dbms_alec
      Hello,

      i have job "MAIN_JOB" which raise event JOB_SUCCEEDED, second job "LITTLE_JOB" consume this event.
      But i have one problem. MAIN_JOB starts chain "MAIN_CHAIN", and always when each step of this chain completed succesfull,
      job "MAIN_JOB" raise event "JOB_SUCCEEDED".
      How to do so "MAIN_JOB" raise event only once, not for each step?

      DBMS_SCHEDULER.CREATE_JOB
      (
      job_name => 'MAIN_JOB'
      ,schedule_name => 'ANY_SCHEDULE'
      ,job_class => 'DEFAULT_JOB_CLASS'
      ,job_type => 'CHAIN'
      ,job_action => 'MAIN_CHAIN'
      );

      DBMS_SCHEDULER.SET_ATTRIBUTE
      ( name => 'MAIN_JOB'
      ,attribute => 'RAISE_EVENTS'
      ,value => DBMS_SCHEDULER.JOB_SUCCEEDED);


      DBMS_SCHEDULER.CREATE_EVENT_SCHEDULE
      (
      schedule_name => 'EVENT_SCHED'
      ,start_date => to_date('01.01.2012 00:00:00','dd.mm.yyyy hh24:mi:ss')
      ,event_condition => 'tab.user_data.object_name = ''MAIN_JOB'' and tab.user_data.event_type = ''JOB_SUCCEEDED'''
      ,queue_spec => 'SYS.SCHEDULER$_EVENT_QUEUE, REPORT'
      ,end_date => NULL
      );


      DBMS_SCHEDULER.CREATE_JOB
      (
      job_name => 'LITTLE_JOB'
      ,schedule_name => 'EVENT_SCHED'
      ,program_name => 'SOME_PROGRAMM'
      ,auto_drop => false
      ,enabled => true
      );


      Thx.

      Edited by: dbms_alec on 13.05.2012 23:44
        • 1. Re: Job event and chain
          spajdy
          This is because for each step of chain a job is run. For your request don't set job attribute to raise event but create a step for chain job that raise this event from code. Put this step as last step in chain job.