Oracle implementation Job Scheduled Tasks

Source: Internet
Author: User
In Oracle database operations, sometimes we need to execute certain stored procedures on a regular basis. How does Oracle do that? Starting with Oracle version 10.1, Oracle has developed a new package dbms_scheduler. This package will help solve the problem of our scheduled tasks. A. New Job 1. Job creation Instance
BEGIN
  Dbms_scheduler. Create_job (job_name => ' job_exwh_bpartner_static ', Job_type => '
                            plsql_block ', job_action => ')
                            DECLARE
io_row number;
Io_status number;
Vo_sqlerr VARCHAR2 (1000);
BEGIN
  -Call stored procedure
  bi_dm. P_f_t_exwh_bparner_static (Sysdate, Io_row, Io_status, vo_sqlerr);
End; ',
                            repeat_interval => ' freq=daily; byhour=15; byminute=00; Bysecond=00;interval=1 ',
                            job_class => ' Default_job_class ',
                            ENABLED => TRUE,
                            auto_drop => FALSE,
                            COMMENTS => ' This is a test ');
End;
2.job StatementDbms_scheduler. Create_job 3.job ParametersJob_name:job name Job_type:job type Plsql_block: Indicates that the task executes a Pl/sql anonymous block. Stored_procedure: Indicates that task execution is a stored procedure. Executable: Indicates that the task performs an external program, such as an operating system command. CHAIN: Indicates that the task executes a CHAIN. Job_action:job Execution Action Repeat_interval:job Schedule Job_class: Specifies the CLASS to which the task is associated, and the default value is Default_job_class ENABLE: Check JOB validity when created Auto_ Drop: The job will be automatically deleted after the job completes or automatically disabled COMMENTS: Memo start_date:job effective time End_date:job end time 4.repeat_interval ParametersFreq:yearly: In the Year Unit Monthly: in the month unit WEEKLY: in the week Unit daily: In the day unit hourly: In the hour unit minutely: in the unit secondly: in the second unit INTERVAL: execution times ByMonthDay : Date in the month Byday: Week Byhour: Hours Byminute: minutes Bysecond: sec two. Query Job
--Query the user for all job
select * from User_scheduler_jobs;
--Query the running job
select * from User_scheduler_running_jobs
three. Run Job
BEGIN
  dbms_scheduler.run_job (use_current_session =>false, job_name => ' job_exwh_bpartner_static ');
End;
four. Delete Job
BEGIN
  dbms_scheduler.drop_job (job_name=> ' job_exwh_bpartner_static ', force=>false);
 End;
Force: If it is FALSE, if there are other jobs that are using this schedule will not delete this schedule, if it is TRUE if no other job use this schedule will delete this schedule.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.