-1

I have an event scheduler in mysql which is executing fine

CREATE event 'STORE' ON schedule every 1 hour doUPDATE c_store
SET    is_active = '0'
WHERE  web_id =
       (
              SELECT web_id
              FROM   c_web
              WHERE  Datediff(Now( ) , createdon ) > 15) 

My query is i want the same in Oracle , can any one guide me.

Lalit Kumar B
  • 47,486
  • 13
  • 97
  • 124
User
  • 11
  • 1

2 Answers2

1

You need to use DBMS_SCHEDULER to create a job and schedule it to run hourly.

For example,

SQL> BEGIN
  2    DBMS_SCHEDULER.DROP_JOB (JOB_NAME => 'test_full_job_definition');
  3  END;
  4  /

PL/SQL procedure successfully completed.

SQL>
SQL> BEGIN
  2    DBMS_SCHEDULER.create_job (
  3      job_name        => 'test_full_job_definition',
  4      job_type        => 'PLSQL_BLOCK',
  5      job_action      => 'BEGIN my_job_procedure; END;',
  6      start_date      => SYSTIMESTAMP,
  7      repeat_interval => 'freq=hourly; byminute=0; bysecond=0;',
  8      end_date        => NULL,
  9      enabled         => TRUE,
 10      comments        => 'Job defined entirely by the CREATE JOB procedure.');
 11  END;
 12  /

PL/SQL procedure successfully completed.

SQL>
SQL> SELECT JOB_NAME, ENABLED FROM DBA_SCHEDULER_JOBS where job_name ='TEST_FULL_JOB_DEFINITION'
  2  /

JOB_NAME                                 ENABL
---------------------------------------- -----
TEST_FULL_JOB_DEFINITION                 TRUE

SQL>

See more examples here

Lalit Kumar B
  • 47,486
  • 13
  • 97
  • 124
0

You must use DBMS_SCHEDULER

Here you can find some examples.

Giovanni
  • 3,951
  • 2
  • 24
  • 30