--Oracle定时器
declare
/*声明 ,任务开始 */
DELETE_LOG_JOB number; /*系统会自动分配一个任务号码,作为标识,相当于表中的主键 */
BEGIN
dbms_job.SUBMIT( /* 格式:任务名.submit(执行的内容,初次执行时间,执行频率); */DELETE_LOG_JOB,
'PRO_SCADA_DELETE;PRO_SCADAT_DELETE;PRO_SCADAT1_DELETE;PRO_SCADAOVEN_DELETE;PRO_SCADA1_DELETE;
PRO_SCADA2_DELETE;PRO_SCADA3_DELETE;PRO_SCADA4_DELETE;PRO_SCADA5_DELETE;PRO_SCADA6_DELETE;
PRO_SCADA7_DELETE;PRO_SCADA8_DELETE;PRO_SCADA9_DELETE;PRO_SCADA10_DELETE;PRO_SCADA11_DELETE;
PRO_SCADA12_DELETE;PRO_SCADA13_DELETE;',
sysdate + 1 / (24 * 60),
'TRUNC(SYSDATE+1)');
commit; /*提交任务 */
end; /*结束 */
CREATE OR REPLACE
PROCEDURE "PRO_SCADA_DELETE" AS
BEGIN
delete from SCADA t where TO_DATE(to_char(t.ts,'yyyy-mm-dd'),'yyyy-mm-dd') < TO_DATE(to_char(sysdate, 'yyyy-mm-dd'),'yyyy-mm-dd')-30;
END;
CREATE OR REPLACE
PROCEDURE "PRO_SCADAT_DELETE" AS
BEGIN
delete from SCADAT t where TO_DATE(to_char(t.ts,'yyyy-mm-dd'),'yyyy-mm-dd') < TO_DATE(to_char(sysdate, 'yyyy-mm-dd'),'yyyy-mm-dd')-30;
END;
CREATE OR REPLACE
PROCEDURE "PRO_SCADAT1_DELETE" AS
BEGIN
delete from SCADAT1 t where TO_DATE(to_char(t.ts,'yyyy-mm-dd'),'yyyy-mm-dd') < TO_DATE(to_char(sysdate, 'yyyy-mm-dd'),'yyyy-mm-dd')-30;
END;
CREATE OR REPLACE
PROCEDURE "PRO_SCADAOVEN_DELETE" AS
BEGIN
delete from SCADAOVEN t where TO_DATE(to_char(t.ts,'yyyy-mm-dd'),'yyyy-mm-dd') < TO_DATE(to_char(sysdate, 'yyyy-mm-dd'),'yyyy-mm-dd')-30;
END;
CREATE OR REPLACE
PROCEDURE "PRO_SCADA1_DELETE" AS
BEGIN
delete from SCADA1 t where TO_DATE(to_char(t.ts,'yyyy-mm-dd'),'yyyy-mm-dd') < TO_DATE(to_char(sysdate, 'yyyy-mm-dd'),'yyyy-mm-dd')-30;
END;
CREATE OR REPLACE
PROCEDURE "PRO_SCADA2_DELETE" AS
BEGIN
delete from SCADA2 t where TO_DATE(to_char(t.ts,'yyyy-mm-dd'),'yyyy-mm-dd') < TO_DATE(to_char(sysdate, 'yyyy-mm-dd'),'yyyy-mm-dd')-30;
END;
CREATE OR REPLACE
PROCEDURE "PRO_SCADA3_DELETE" AS
BEGIN
delete from SCADA3 t where TO_DATE(to_char(t.ts,'yyyy-mm-dd'),'yyyy-mm-dd') < TO_DATE(to_char(sysdate, 'yyyy-mm-dd'),'yyyy-mm-dd')-30;
END;
CREATE OR REPLACE
PROCEDURE "PRO_SCADA4_DELETE" AS
BEGIN
delete from SCADA4 t where TO_DATE(to_char(t.ts,'yyyy-mm-dd'),'yyyy-mm-dd') < TO_DATE(to_char(sysdate, 'yyyy-mm-dd'),'yyyy-mm-dd')-30;
END;
CREATE OR REPLACE
PROCEDURE "PRO_SCADA5_DELETE" AS
BEGIN
delete from SCADA5 t where TO_DATE(to_char(t.ts,'yyyy-mm-dd'),'yyyy-mm-dd') < TO_DATE(to_char(sysdate, 'yyyy-mm-dd'),'yyyy-mm-dd')-30;
END;
CREATE OR REPLACE
PROCEDURE "PRO_SCADA6_DELETE" AS
BEGIN
delete from SCADA6 t where TO_DATE(to_char(t.ts,'yyyy-mm-dd'),'yyyy-mm-dd') < TO_DATE(to_char(sysdate, 'yyyy-mm-dd'),'yyyy-mm-dd')-30;
END;
CREATE OR REPLACE
PROCEDURE "PRO_SCADA7_DELETE" AS
BEGIN
delete from SCADA7 t where TO_DATE(to_char(t.ts,'yyyy-mm-dd'),'yyyy-mm-dd') < TO_DATE(to_char(sysdate, 'yyyy-mm-dd'),'yyyy-mm-dd')-30;
END;
CREATE OR REPLACE
PROCEDURE "PRO_SCADA8_DELETE" AS
BEGIN
delete from SCADA8 t where TO_DATE(to_char(t.ts,'yyyy-mm-dd'),'yyyy-mm-dd') < TO_DATE(to_char(sysdate, 'yyyy-mm-dd'),'yyyy-mm-dd')-30;
END;
CREATE OR REPLACE
PROCEDURE "PRO_SCADA9_DELETE" AS
BEGIN
delete from SCADA9 t where TO_DATE(to_char(t.ts,'yyyy-mm-dd'),'yyyy-mm-dd') < TO_DATE(to_char(sysdate, 'yyyy-mm-dd'),'yyyy-mm-dd')-30;
END;
CREATE OR REPLACE
PROCEDURE "PRO_SCADA10_DELETE" AS
BEGIN
delete from SCADA10 t where TO_DATE(to_char(t.ts,'yyyy-mm-dd'),'yyyy-mm-dd') < TO_DATE(to_char(sysdate, 'yyyy-mm-dd'),'yyyy-mm-dd')-30;
END;
CREATE OR REPLACE
PROCEDURE "PRO_SCADA11_DELETE" AS
BEGIN
delete from SCADA11 t where TO_DATE(to_char(t.ts,'yyyy-mm-dd'),'yyyy-mm-dd') < TO_DATE(to_char(sysdate, 'yyyy-mm-dd'),'yyyy-mm-dd')-30;
END;
CREATE OR REPLACE
PROCEDURE "PRO_SCADA12_DELETE" AS
BEGIN
delete from SCADA12 t where TO_DATE(to_char(t.ts,'yyyy-mm-dd'),'yyyy-mm-dd') < TO_DATE(to_char(sysdate, 'yyyy-mm-dd'),'yyyy-mm-dd')-30;
END;
CREATE OR REPLACE
PROCEDURE "PRO_SCADA13_DELETE" AS
BEGIN
delete from SCADA13 t where TO_DATE(to_char(t.ts,'yyyy-mm-dd'),'yyyy-mm-dd') < TO_DATE(to_char(sysdate, 'yyyy-mm-dd'),'yyyy-mm-dd')-30;
END;