Solved

create a job using job scheduler

Posted on 2008-10-19
3
623 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

706 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now