Home  >  Article  >  Database  >  How to set Oracle scheduled task to be executed every half hour

How to set Oracle scheduled task to be executed every half hour

下次还敢
下次还敢Original
2024-04-18 16:03:121048browse

Oracle scheduled tasks can be set to be executed every half hour through the following steps: 1. Create a scheduled task and set the repeat interval to 30 minutes. 2. Create a task and specify the scheduled task name and stored procedure as the task operation. 3. Create a stored procedure that contains the logic that needs to be executed. 4. Enable scheduled tasks.

How to set Oracle scheduled task to be executed every half hour

How to set Oracle scheduled tasks to be executed every half hour

1. Create scheduled tasks

<code class="SQL">BEGIN
  DBMS_SCHEDULER.CREATE_SCHEDULE(
    schedule_name => 'JOB_SCHEDULE',
    start_date => SYSDATE,
    repeat_interval => 'FREQ=MINUTELY;INTERVAL=30',
    end_date => NULL
  );
END;
/</code>

2. Create tasks

<code class="SQL">BEGIN
  DBMS_SCHEDULER.CREATE_JOB(
    job_name => 'JOB_NAME',
    job_type => 'STORED_PROCEDURE',
    schedule_name => 'JOB_SCHEDULE',
    job_action => 'BEGIN EXECUTE_JOB(); END;'
  );
END;
/</code>

3. Create a stored procedure to execute scheduled tasks

<code class="SQL">CREATE OR REPLACE PROCEDURE EXECUTE_JOB
AS
BEGIN
  -- 在此处编写需要执行的任务逻辑
END;
/</code>

4. Enable scheduled tasks

<code class="SQL">BEGIN
  DBMS_SCHEDULER.ENABLE(job_name => 'JOB_NAME');
END;
/</code>

The above is the detailed content of How to set Oracle scheduled task to be executed every half hour. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn