Search code examples
oraclestored-proceduresoracle11gjobs

Oracle job to run daily in Oracle Express edition 11g


![enter image description here][1]

I just updated with a new version of the database. I've previously used Oracle database versioyon 10. Now I installed Oracle 11g Express edition.

I had the three jobs on the DBMS_jobs.

I programmed it to run them at a particular time on a daily basis. every day at 01:00 in the stored procedure was running on a regular basis.

begin
  sys.dbms_job.submit(job => :job,
  what => 'BEGIN CALL_MY_SP; END;',
  next_date => to_date('24-09-2013 01:00:00', 'dd-mm-yyyy hh24:mi:ss'),
   interval => 'TRUNC(SYSDATE + 1) + 1/24');
  commit;
end;

Although the same job to the new Oracle database running. But this job is manually executing.

How do I run automatically on a regular basis every day? But What if I did not!

https://i.sstatic.net/rePVq.png

your job

http://l1309.hizliresim.com/1f/s/sz6pg.png


Solution

  • To run manually, try:

    exec dbms_scheduler.run_job('MY_JOB',false);
    

    and to stop manually, use:

    exec dbms_scheduler.stop_job('MY_JOB',false);
    

    If your question is how to scheduler a job in Oracle, its a big topic (see Documentation ), but a simple example would be:

    BEGIN
    
      dbms_scheduler.create_job(
        job_name=>'JOB_TEST2',
        job_type=>'PLSQL_BLOCK',
        job_action=>'BEGIN
        dbms_lock.sleep(10);
        END;',
        start_date=>systimestamp,
        repeat_interval=>'FREQ=MINUTELY;INTERVAL=1',
        number_of_arguments=>0,
        enabled=>TRUE,
        comments=>'Job duration is 10 seconds, launches every minute'
      );
    
    END;
    

    Since it was created as enabled, it will start running automatically. You can verify this looking at the logs (dba_scheduler_job_run_details) and can view basic attributes via dba_scheduler_jobs