Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Finished scheduled job not dropped

InoLJul 27 2009 — edited Jul 28 2009
This was already posted in the Scheduler forum, but I guess more people watch this forum. Sorry for the double post.


I am creating two jobs where the 2nd waits for the first to finish. The code example was taken from this thread: 2458833
begin
  dbms_scheduler.create_job (
    job_name => 'j1',job_type => 'plsql_block',
    job_action =>  'insert into test_event values(systimestamp, ''first job runs'');commit;',
    enabled => false,
    auto_drop => true);
  dbms_scheduler.set_attribute('j1', 'raise_events', DBMS_SCHEDULER.JOB_SUCCEEDED);
end;
 
begin
  dbms_scheduler.create_job('j2',
    job_type=>'plsql_block',
    job_action=>'insert into test_event values(systimestamp, ''second job runs'');commit;',
    event_condition => 'tab.user_data.object_name = ''J1''',
    queue_spec =>'sys.scheduler$_event_queue,job$_agent',
    enabled=>true,
    auto_drop => true);
end;
 
begin
  -- Enable the first job so that it starts running
  dbms_scheduler.enable('j1');
end;
This works (j1 and j2 run in order), but the 2nd job (j2) is not removed from user_scheduler_jobs after completion. The state remains SCHEDULED.
This is a problem since I want to execute the code many times. This now results in:

ORA-27477: "J2" already exists
ORA-06512: at "SYS.DBMS_ISCHED", line 99
ORA-06512: at "SYS.DBMS_SCHEDULER", line 295
ORA-06512: at line 2

I can, of course, drop job j2 before creating it again, but I am wondering why j2 is not automatically removed.

Version is Oracle Database 10g Express Edition Release 10.2.0.1.0
This post has been answered by 650635 on Jul 28 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 25 2009
Added on Jul 27 2009
8 comments
5,770 views