Oracle job creation example
-- 1. Learning jobs in plsql
-- Learning job
-- Create a table
Create table test_job (para_date date );
Commit;
Insert into test_job values (sysdate );
Commit;
Select * from test_job;
-- Establish the storage process
Create or replace procedure test_jobproce
Begin
Insert into test_job values (sysdate );
End test_jobproce;
-- Create a job
-- After a job is created, it is executed by default.
Declare test_job_really number;
Begin
Dbms_job.submit (test_job_really, 'test _ jobproce; ', sysdate, 'sysdate + 100 ');
Commit;
End;
--- Stop job 25 is the created job test_job_really
Begin
Dbms_job.broken (25, True );
Commit;
End;
-- Start job
Begin
Dbms_job.run (25);
Commit;
End;
-- Delete a job
Begin
Dbms_job.remove (25);
Commit;
End;
-- View execution results
Select * from test_job order by test_job.para_date desc;
-- View job
Select * from sys. user_jobs
-- Use the following SQL statement to check whether the JOB is still Running, provided that the job execution time is not too short.
Select * from dba_jobs_running
-- In addition to the submit parameter, the following parameters are available:
-- Run job
Dbms_job.run (v_job );
-- Stop a job. The parameter true in the job is false, and next_date (stop at a certain time) is also sysdate (stop immediately ).
Dbms_job.broke (v_job, true, next_date );
-- Delete a job
Dbms_job.remove (v_job );
Dbms_job.what (v_job, 'SP _ fact_charge_code ;');
-- Modify the next running time of a job name
Dbms_job.next_date (v_job, sysdate );