Create and delete jobs in PL/SQL

Source: Internet
Author: User
  1. Learning jobs in PLSQL
  2. -- Learning job
  3. -- Create a table
  4. Create Table test_job (para_date
    Date );
  5. Commit;
  6. Insert into test_job
    Values (sysdate );
  7. Commit;
  8. Select * From test_job;
  9. -- Establish the storage process
  10. Create or
    Replace procedure test_jobproce
    As
  11. Begin
  12. Insert into test_job
    Values (sysdate );
  13. End test_jobproce;
  14. -- Create a job
  15. -- After a job is created, it is executed by default.
  16. Declare test_job_really number;
  17. Begin
  18. Dbms_job.submit (test_job_really, 'test _ jobproce; ', sysdate, 'sysdate + 100 ');
  19. Commit;
  20. End;
  21. --- Stop job 25 is the created job test_job_really
  22. Begin
  23. Dbms_job.broken (25, true );
  24. Commit;
  25. End;
  26. -- Start job
  27. Begin
  28. Dbms_job.run (25 );
  29. Commit;
  30. End;
  31. -- Delete a job
  32. Begin
  33. Dbms_job.remove (25 );
  34. Commit;
  35. End;
  36. -- View execution results
  37. Select * From test_job
    Order by test_job.para_date
    DESC;
  38. -- View job
  39. Select * From SYS. user_jobs
  40. -- Use the following SQL statement to check whether the job is still running, provided that the job execution time is not too short.
  41. Select * From dba_jobs_running
  42. In addition to the submit parameter, the following parameters are available:
  43. Dbms_job.run (v_job); // run the job
  44. Dbms_job.broken (v_job, true, next_date); // stop a job. The true parameter in the job is also false, and next_date (stops at a certain time) is sysdate (stops immediately ).
  45. Dbms_job.remove (v_job); // deletes a job.
  46. Dbms_job.what (v_job, 'SP _ fact_charge_code; '); // modify a job name
  47. Dbms_job.next_date (v_job, sysdate); modifies the next running time

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.