Add scheduled task operations to the Oracle database

Source: Internet
Author: User

We generally create related jobs on SQL Server to regularly execute some tasks. In Oracle databases, we usually adopt encoding, call the stored procedure through the corresponding scheduled task framework provided by some projects. Today, we found that it is much easier to create a scheduled task in Oracle than SQL Server.

1. Create a scheduled task:

SQL code

 
 
  1. X NUMBER;  
  2. GIN  
  3. SYS.DBMS_JOB.SUBMIT(job => X,  
  4. what => 'PROC_YKTSJTB;',  

Stored Procedure name

 
 
  1. next_date => trunc(sysdate+5/1440,'MI'), 

Next execution time

 
 
  1. interval => 'trunc(sysdate+1440/1440,''MI'')', 

Interval

 
 
  1. no_parse => FALSE);  
  2. SYS.DBMS_OUTPUT.PUT_LINE('Job Number is: ' || to_char(x));  
  3. COMMIT;  
  4. D;  
  5. X NUMBER;  
  6. BEGIN  
  7. SYS.DBMS_JOB.SUBMIT(job => X,  
  8. what => 'PROC_YKTSJTB;',  

Stored Procedure name

 
 
  1. next_date => trunc(sysdate+5/1440,'MI'), 

Next execution time

 
 
  1. interval => 'trunc(sysdate+1440/1440,''MI'')', 

Interval

 
 
  1. no_parse => FALSE);  
  2. SYS.DBMS_OUTPUT.PUT_LINE('Job Number is: ' || to_char(x));  
  3. COMMIT;  
  4. END;  

Pay attention to the following three parameters:

What: Actions to be executed by the task;

Next_date: the time when the next scheduled task is executed. The specific time can be constructed according to the trunc of the Oracle database;

Interval: The execution cycle of the scheduled task;

2. scheduled task execution monitoring

SQL code

 
 
  1. select * from user_jobs; 

View scheduled tasks

 
 
  1. select * from dba_jobs_running; 

View ongoing scheduling tasks

 
 
  1. select * from dba_jobs; 

View completed scheduling tasks

The above content describes how to add scheduled tasks to the Oracle database, hoping to help you in this regard.

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.