Solved

create a job using job scheduler

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and theā€¦
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

785 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