Things we need
1. sample table
2. stored procedure that will do the insert
3. oracle scheduled job to execute the stored procedure.
CREATE TABLE BKUP_TEST
(
COL1 VARCHAR2(20 BYTE),
CAP_DATE TIMESTAMP(6) DEFAULT current_timestamp,
USERNAME VARCHAR2(10 BYTE) DEFAULT user
);
2. Create the procedure
CREATE OR REPLACE PROCEDURE INS_BKPTST
IS
BEGIN
insert into bkup_test(col1) values('Marines');
COMMIT;
END;
/
3
BEGIN
SYS.DBMS_SCHEDULER.CREATE_JOB
(
job_name => 'SYS.HOURLY_INSERT'
,start_date => TO_TIMESTAMP_TZ('2020/04/30 20:03:43.996546 +08:00','yyyy/mm/dd hh24:mi:ss.ff tzh:tzm')
,repeat_interval => 'FREQ=hourly;'
,end_date => NULL
,job_class => 'DEFAULT_JOB_CLASS'
,job_type => 'STORED_PROCEDURE'
,job_action => 'INS_BKPTST'
,comments => NULL
);
END;
/
SAMPLE
Marines 5/12/2020 10:03:43.260792 AM SYS
Marines 5/12/2020 9:03:43.129653 AM SYS
Marines 5/12/2020 8:03:44.021578 AM SYS
Marines 5/12/2020 7:03:43.877183 AM SYS
No comments:
Post a Comment