1. 寫一支搬資料的stored procedure
2. 設定它每30分鐘跑起來搬資料(利用DBMS_SCHEDULER)
Stored Procedure
create or replace
PROCEDURE MOVE_CAR_TRACE_LOG_TO_HISTORY AS
cut_date DATE := sysdate -(1/48);
BEGIN
insert into car_trace_log_his(car_no, create_date, latitude, longitude, location, flag)
select car_no, create_date, Y, X, location, flag
from car_trace_log
where create_date <>
delete car_trace_log where create_date <>
commit;
END MOVE_CAR_TRACE_LOG_TO_HISTORY;
Run scheduler:
BEGIN
DBMS_SCHEDULER.CREATE_JOB(job_name =>'SP_Move_car_log_data',
job_type =>'STORED_PROCEDURE',
job_action =>'MOVE_CAR_TRACE_LOG_TO_HISTORY',
start_date => SYSTIMESTAMP,
repeat_interval =>'FREQ=MINUTELY; INTERVAL=30',
enabled=>TRUE);
END;
No comments:
Post a Comment