Solved

create a job using job scheduler

Posted on 2008-10-19
3
625 Views
Last Modified: 2013-12-18
sir
The job scheduler in oem is used to schedule job..
we can create job using pl/sql in that..
But I don't know how to create a job..In which occastion we create job using pl/sql
Can any expert help me with example
0
Comment
Question by:dbaseek
  • 2
3 Comments
 
LVL 4

Expert Comment

by:hqassap
ID: 22755609
Hi,

To create a scheduled job:

BEGIN
sys.dbms_scheduler.create_schedule(
repeat_interval => 'FREQ=DAILY;BYHOUR=3;BYMINUTE=0;BYSECOND=0',
start_date => systimestamp at time zone '+3:00',
schedule_name => '"SYS"."TEST"');
END;


To modify a scheduled job:

BEGIN
sys.dbms_scheduler.disable( '"SYS"."TEST"' );
sys.dbms_scheduler.set_attribute( name => '"SYS"."TEST"', attribute => 'repeat_interval', value => 'FREQ=SECONDLY');
sys.dbms_scheduler.enable( '"SYS"."TEST"' );
END;
0
 
LVL 28

Accepted Solution

by:
Naveen Kumar earned 500 total points
ID: 22756123
-- below are some examples...
-- first create a program to call the pl/sql procedure which you want...

BEGIN
DBMS_SCHEDULER.CREATE_PROGRAM(
PROGRAM_NAME => 'CHECK_EXCHANGE_RATES_PROG',
PROGRAM_TYPE => 'PLSQL_BLOCK',
PROGRAM_ACTION => 'begin pkg_mail_dist.check_ex_rates; end;',
NUMBER_OF_ARGUMENTS => 0,
ENABLED => TRUE,
COMMENTS => 'This program is to call pkg_adm_mail_dist.check_exchange_rates.');
END;

select * from dba_scheduler_programs --> this query will help you to see the above created  
                                                              --> program

-- below is to setup a job which runs at 06:30 hrs everyday

BEGIN
dbms_scheduler.create_job(
job_name => 'CHECK_EXCHANGE_RATES_JOB',
program_name   => 'CHECK_EXCHANGE_RATES_PROG',
start_date      => systimestamp,
--start_date      => '04-apr-2008 00:00:00 EUROPE/LONDON BST', -- commented
repeat_interval => 'freq=daily; byhour=6; byminute=30; bysecond=0',
enabled         => TRUE,
auto_drop       => FALSE ,
comments   => 'This job runs everyday at 6:30 AM');
END;
/

-- you can use the below if you want to change the frequency of the job....
BEGIN
  DBMS_SCHEDULER.set_attribute (
    name      => 'CHECK_EXCHANGE_RATES_JOB',
    attribute => 'repeat_interval',
    value     => 'freq=daily; byday=mon,tue,wed,thu,fri; byhour=6; byminute=30; bysecond=0'
      );
END;
/

-- to drop the created job
BEGIN
dbms_scheduler.drop_job(job_name =>  'CHECK_EXCHANGE_RATES_JOB');
END;
/

-- also you can use the below queries...

SELECT * FROM dba_scheduler_jobs

SELECT * FROM dba_scheduler_job_log
ORDER BY 1 DESC

SELECT * FROM dba_scheduler_job_run_details
ORDER BY 1 DESC

Thanks
0
 
LVL 28

Expert Comment

by:Naveen Kumar
ID: 22756141
http://www.psoug.org/reference/dbms_scheduler.html
http://www.oracle-base.com/articles/10g/Scheduler10g.php

For a better understanding, just browse through the above links. I am sure it is going to give you a good understanding.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question