Solved

create a job using job scheduler

Posted on 2008-10-19
3
627 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

623 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