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;
/