Oracle job, oracle

Source: Internet
Author: User

Oracle job, oracle
Enable the specified job:
BEGIN
Dbms_auto_task_admin.enable (
Client_name => 'SQL tuning advisor ',
Peration => NULL,
Window_name => 'Monday _ window ');
END;
/
How to Create a job in oracle

Replace the following stored procedure name with the actual stored procedure name to implement the functions you want,
Now you can directly execute it in pl/SQL dev. If you have any questions, contact me.
The above section is about deleting a job, followed by creating a job. I wrote a judgment statement and can execute it at will.
Refer to the dbms_job package of oracle.

--------------------- Lili split line ----------------------------
DECLARE
I _count number;
Job_num number;
BEGIN
Select count (job) into I _count from user_jobs where upper (what) = 'stored procedure name ;';
If I _count> 0 then
Select job into job_num from user_jobs where upper (what) = 'stored procedure name ;';
Dbms_job.remove (job_num );
End if;
END;
/
Commit;
Declare x number;
BEGIN
DBMS_JOB.SUBMIT
(Job => X
, What => 'stored procedure name ;'
, Next_date => to_date (to_char (sysdate + 1, 'yyyy-mm-dd') | '01:00:00 ', 'yyyy-mm-dd hh24: mi: ss ')
, Interval => 'sysdate + 1'
, No_parse => TRUE
);
END;
/
Commit;


Oracle job timing task, positive solution, no need to post online search

Database Job

Job creation

Syntax:

DBMS_JOB.SUBMIT (
Job OUT BINARY_INTEGER,
What IN VARCHAR2, NEXT_DATE in date defaultsysdate,
Interval IN VARCHAR2 DEFAULT 'null ',
No_parse in boolean default false,
Instance IN BINARY_INTEGER DEFAULT ANY_INSTANCE,
Force in boolean default false );

What is the PL/SQL code that needs to be called regularly
Interval indicates the next job running time.

SQL> create table jjk (a date );
The table has been created.

SQL> create or replace procedure test1
2 begin
3 insert into jjk values (sysdate );
4 end test1;
5/
The process has been created.

SQL> variable jobno number;
SQL> begin
2 dbms_job.submit (: jobno, 'test1; ', trunc (sysdate + 1/24, 'hh'), 'trunc (SYSDATE + 1/24, 'hh '')');
3 commit;
4 end;
5/
The PL/SQL process is successfully completed.

Job Query

SQL> SELECT job, what FROM user_jobs;

JOB
----------
WHAT
-------------------------------------
21
Test1;

Job Modification

Modify the stored procedure, next execution time, and cycle of a job.
Dbms_job.CHANGE (job, what, next_date, interval );
Only modify the stored procedure of job execution
Dbms_job.WHAT (job, what );
Only modify the next job execution time
Dbms_job.NEXT_DATE (job, next_date );
Only modify the job execution cycle.
Dbms_job.INTERVAL (job, interval );

Delete a job

SQL> begin
2 dbms_job.remove (21 );
3 commit;
4 end;
5/

PL/SQL process completed successfully .... Remaining full text>

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.