Oracle job creation, Oracle Exception Handling

Source: Internet
Author: User

Run the command in the Command window.

Variable names after variable must be the same as those after job =>: job. Otherwise, the error "Not all variables are bound" will be reported. After successful execution, the job number is automatically generated by Oracle.

Generally, Oracle exception handling is added to the stored procedure when a job is called. Otherwise, the error cannot be found after a job error occurs.

1. Create a job(Note that next_date must be written! Time is required)

variable job1 number;begin  sys.dbms_job.submit(job => :job1,                      what => 'p_main3_main1;',                      next_date => to_date('01-02-2012 11:47:25', 'dd-mm-yyyy hh24:mi:ss'),                      interval => 'SYSDATE+4/86400/5');  commit;end;/

2. Oracle Exception Handling (during storage)

2.1 create an error log table first

create table t_sys_errors(e_user varchar2(100),e_date date,error_code number,error_message varchar2(255)) ;

2.2 exception records in the log table during storage

Declare error_code number; --> defines the variable, error_message varchar2 (255); --> 11g is 512, 10g is 255 begin... exception when others then rollback; error_code: = sqlcode; --> put the error code in the variable error_message: = sqlerrm --> put the error message into the variable and insert into errors (e_user, e_date, error_code, error_message) values (user, sysdate, error_code, error_message); --> put the error code and information in the log table end;

 

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.