Oracle 10g – How to Auto Update a Column Every 24 Hours

oracleoracle-10g

I want to reset the values of a column every 24 hours. Is it possible? The column contains numeric values.

It's a ticket reservation system. I need to reset the number of tickets.

Best Answer

Sure, just create a job. For example, update column every midnight:

begin
  dbms_scheduler.create_job
  (
   job_name             => 'UPDATE_TABLE',
   job_type             => 'PLSQL_BLOCK',
   job_action           => 'begin update table set column = value; commit; end;',
   start_date           => trunc(sysdate+1),
   repeat_interval      => 'FREQ=DAILY;BYHOUR=0;BYMINUTE=0',
   enabled              => TRUE,
   auto_drop            => FALSE
  );
end;
/