Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

create a job using job scheduler

Posted on 2008-10-19
3
Medium Priority
?
628 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

715 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