Usage Demo:
Dbms_job.submit (: jobno, // job no.
'Your _ procedure; ', // process to be executed
Trunc (sysdate) + 1/24, // next execution time
'Trunc (sysdate) + 1/24 + 1' // Interval
);
Delete job: dbms_job.remove (jobno );
Modify the operation to be executed: Job: dbms_job.what (jobno, what );
Modify the next execution time: dbms_job.next_date (job, next_date );
Interval of modification: dbms_job.interval (job, interval );
Stop job: DBMS. Broken (job, broken, nextdate );
Start Job: dbms_job.run (jobno );
Appendix: Call statements and parameter descriptions:
Dbms_job.submit (job out binary_integer,
What in archar2,
Next_date in date,
Interval in varchar2,
No_parse in Boolean)
Where:
● Job: output variable, which is the number of the task in the task queue;
● What: the name of the task to be executed and its input parameters;
● Next_date: the time when the task is executed;
● Interval: The interval between tasks.
Demo example:
Declare
Jobid number;
V_ SQL varchar2 (2000 );
Begin
V_ SQL: = 'begin'
If to_char (sysdate, ''hh24: mi'') = ''15: 30 ''then -- execute
Insert into CK. rkjl (cksj) Select cksj from wzcs. ckjl;
Dbms_output.put_line (''serted success '');
End if;
Commit;
Exception
When others then
Rollback;
Dbms_output.put_line (sqlerrm );
End;
';
Dbms_job.submit (jobid, v_ SQL, sysdate, 'sysdate + 1/1440 ');
Dbms_job.run (jobid );
Dbms_output.put_line ('job' | to_char (jobid) | 'Is running ');
End;