Use of dbms_job in oracle (scheduled task)

Source: Internet
Author: User

The use of dbms_job (scheduled task) in oracle can be considered as a scheduled task. 1. CREATE test TABLE SQL code CREATE TABLE TEST_DATE (A DATE); 2. CREATE a custom process SQL code CREATE OR REPLACE PROCEDURE TEST_MYPROC AS BEGIN INSERT INTO TEST_DATE VALUES (SYSDATE); COMMIT; END; 3. create JOB (Command window) SQL code VARIABLE JOB1 NUMBER; BEGIN DBMS_JOB.SUBMIT (: JOB1, 'test _ MYPROC; ', SYSDATE, 'sysdate + 1/1440'); -- 1440 minutes a day, that is, the TEST process is run once at one minute. 4. run JOBSql code BEGIN DBMS_JOB.RUN (: JOB1); END; 5. delete JOBSql code BEGIN DBMS_JOB.REMOVE (: JOB1); END; job running time 1: Execute Interval => TRUNC (sysdate, 'mi') + 1/(24*60) 2: daily scheduled execution example: Execute Interval => TRUNC (sysdate) + 1 + 1/(24) 3: weekly scheduled execution example: execute Interval => TRUNC (next_day (sysdate, 'monday') + 1/244 at every Monday: execute Interval => TRUNC (LAST_DAY (SYSDATE) + 1 + 1/245 at on the first day of each month: perform scheduled execution on a quarterly basis. For example, execute Interval => TRUNC (ADD_MONTHS (SYSDATE, 3), 'q') + 1/246 at on the first day of each quarter. For example: interval => ADD_MONTHS (trunc (sysdat E, 'yyyy'), 6) + 1/247: scheduled execution every year. For example, execute Interval => ADD_MONTHS (trunc (sysdate, 'yyyy'), 12) at on January 1, January 1) + 1/24 set the Running frequency of a job. run at a fixed time every day, such as a.m.: Trunc (Sysdate + 1) + (8*60 + 10)/24*602. provided in Toad: daily: trunc (sysdate + 1) Weekly: trunc (sysdate + 7) Monthly: trunc (sysdate + 30) every Sunday: next_day (trunc (sysdate ), 'sunday') every day: trunc (sysdate + 1) + 6/24 half an hour: sysdate + 30/14403. 15th minutes of operation per hour, such as: 8: 15, 9: 15, 10: 15...: trunc (sysdate, 'hh') + 75/1440. 4. use the following SQL statement to query whether the JOB is still in Runningselect * from dba_jobs_running. Some key parameters are described as follows: DBMS_JOB.SUBMIT (: jobno, // job no. 'Your _ procedure ;', // The process to be executed trunc (sysdate) + 1/24, // The next execution time 'trunc (sysdate) + 1/24 + 1' // each interval); Delete the job: dbms_job.remove (jobno); Modify job: dbms_job.what (jobno, what); Modify next execution time: dbms_job.next_date (job, next_date); interval: dbms_job.interval (job, job, interval); stop job: dbms. broken (job, broken, nextdate); start job: dbms_job.run (jobno); Modify job_queue_processes value: (ensure it is not 0 or the JOB is not automatically run) you can use select * from v $ parameter; to view its VALUE, or directly use show parameter job_queue_processes; to view the following information: name type value ------------------- ------------ job_queue_processes integer 10

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.