Oracle job creation example

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.