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
- X NUMBER;
- GIN
- SYS.DBMS_JOB.SUBMIT(job => X,
- what => 'PROC_YKTSJTB;',
Stored Procedure name
- next_date => trunc(sysdate+5/1440,'MI'),
Next execution time
- interval => 'trunc(sysdate+1440/1440,''MI'')',
Interval
- no_parse => FALSE);
- SYS.DBMS_OUTPUT.PUT_LINE('Job Number is: ' || to_char(x));
- COMMIT;
- D;
- X NUMBER;
- BEGIN
- SYS.DBMS_JOB.SUBMIT(job => X,
- what => 'PROC_YKTSJTB;',
Stored Procedure name
- next_date => trunc(sysdate+5/1440,'MI'),
Next execution time
- interval => 'trunc(sysdate+1440/1440,''MI'')',
Interval
- no_parse => FALSE);
- SYS.DBMS_OUTPUT.PUT_LINE('Job Number is: ' || to_char(x));
- COMMIT;
- 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
- select * from user_jobs;
View scheduled tasks
- select * from dba_jobs_running;
View ongoing scheduling tasks
- 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.