Oracle timing script

Source: Internet
Author: User

I have been using Linux Crontab and suddenly want to use Oracle to write a simple job.

Create Table Test (
Car_no varchar2 (30 ),
Car_info_id number );

 

 

Create or replace procedure pro_test
As
Carinfo_id number;
Begin
Select test_seq.nextval into carinfo_id from dual;
Insert into test (car_no, car_info_id) values (carinfo_id, 123 );
Commit;
End pro_test;
/

The meaning of the dbms_job.submit parameter is as follows:

 

Variable job number;
Begin
Dbms_job.submit (
Job =>: Job,/* automatically generate job_id */
What => 'create _ task_by_plan; ',/* process or SQL statement to be executed */
Next_date => trunc (sysdate + 1) + 6/24,/* initial execution time */
Interval => 'trunc (sysdate + 1) + 1000');/* execution cycle */
Commit;
End;

 

 

 

Variable jobno number;
Begin
Dbms_job.submit (: jobno, 'Pro _ test ;',
Sysdate, 'sysdate + 1/24/12'); = "here to write sysdate + specific execution frequency or else (ORA-00932: inconsistent data type: number is required for date)
Commit;
End;
/

The last step is run.

Begin
Dbms_job.run (: Job );
End;
/

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.