Skip to content

Insight and analysis of technology and business strategy

DBMS_SCHEDULER and Implicit Commits

As usual, Oracle introduces new features, and we read the documentation about how they work and we start using them… but what about what is not in the documentation? That we find out by practice, experience, or accident. And that is exactly what happened to me today. Whenever I write a procedure to be called from the scheduler (and previously via dbms_job), if I expect the changes I make to the data to be permanent, I explictly add a commit to the code. This makes the intention obvious to myself and others reviewing my code in the future. Today, I was reviewing someone else's code. It was a packaged procedure that was called by the scheduler and it did not have a commit. I was curious to determine how the scheduler handles this. Does the scheduler issue an implicit commit? I scanned the online documentation and did not find any reference to whether the Oracle scheduler does implicit commits. I googled and did not find any articles that covered it. So I did what every other DBA would do -- I created a test case to prove it one way or the other. Here are the steps I took.
    1. Create the test table.
SQL> create table babette ( thedate date, timesupdate number);
 SQL> insert into babette values ( sysdate, 0, null, null);
 SQL> commit;
 SQL> select to_char(thedate, 'YYYY/MM/DD HH24:MI:SS'), timesupdate from babette;
 ------------------- -----------
 2007/02/26 14:50:21 0
    1. Create the procedure.
SQL> create or replace procedure update_babette is
  2 begin
  3 update babette set thedate = sysdate, timesupdate = timesupdate + 1;
  4 end;
  5 /
    1. Create the Scheduler job.
  job_name => 'BABETTE_JOB',
  job_type => 'STORED_PROCEDURE',
  job_action => 'avail.update_babette',
  start_date => sysdate,
  repeat_interval => 'FREQ=MINUTELY',
  enabled => TRUE);
    1. Confirm that the job is running.
select log_id, to_char(log_date,'YYYY/MM/DD HH24:MI') log_date,
  owner, job_name, status,
  to_char(req_start_date, 'YYYY/MM/DD HH24:MI') start_date,
  to_char(actual_start_date,'YYYY/MM/DD HH24:MI') actual_start_dt
 where job_name = 'BABETTE_JOB' and actual_start_date > sysdate - 5 
 order by owner, actual_start_dt;
 432292 2007/02/26 15:10 AVAIL BABETTE_JOB SUCCEEDED 2007/02/26 15:10 
 432294 2007/02/26 15:11 AVAIL BABETTE_JOB SUCCEEDED 2007/02/26 15:11
    1. Check if the table updates are kept and visible to other sessions.
SQL> select to_char(thedate, 'YYYY/MM/DD HH24:MI:SS'), timesupdate from babette;
 ------------------- -----------
 2007/02/26 15:10:23 3
So yes, it does an implicit commit.

Top Categories

  • There are no suggestions because the search field is empty.

Tell us how we can help!