ORACLE-005: create JOB (1), oracle005 create job
Jobs are widely used in practical applications. Generally, you can regularly execute certain functions and stored procedures. The following describes how to create and start a JOB.
For example, you can use a job to regularly execute a stored procedure.
Stored Procedure name: Pro_Test_JOB
Execution interval: 2 hours,
The SQL statement is as follows:
Declare job number; v_count number; begin select count (*) INTO v_count FROM user_jobs uj WHERE upper (uj. what) = UPPER ('Pro _ Test_JOB; '); if v_count = 0 then sys. dbms_job.submit (job => job, what => 'Pro _ Test_JOB; ', next_date => sysdate, interval => 'sysdate + 2/24'); dbms_job.run (job); commit; end if; end;
Here are several main parameters to describe.
Job-is the ID of the JOB, which is automatically generated.
What-job content. If a job with parameters is included, a script is provided here.
Next_date-next execution time.
Interval-execution frequency.
Here is a job without parameters. If you need to enter parameters to write SQL statements, read the next article.