以windos下为例,其他环境下大同小异。
1、登录sql/plus的批处理
exec_proc.bat
sqlplus irsadmin/irsadmin @D:/IRS_EXEC/exec_body.sql >>D:/IRS_EXEC/proc_exec.log
2、sql/plus调用的SQL脚本
exec_body.sql
DECLARE V_ETLDATE VARCHAR2(8); O_RUNSTATUS NUMBER; O_MSG VARCHAR2(256); BEGIN SELECT TO_CHAR(SYSDATE,'YYYYMMDD') INTO V_ETLDATE FROM DUAL; SP_DELETE_RUBBISH(V_ETLDATE, O_RUNSTATUS, O_MSG); END; / EXIT
3、日志
proc_exec.log
SQL*Plus: Release 10.2.0.1.0 - Production on 星期三 6月 2 11:21:20 2010 Copyright (c) 1982, 2005, Oracle. All rights reserved. 连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options PL/SQL 过程已成功完成。 从 Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options 断开 SQL*Plus: Release 10.2.0.1.0 - Production on 星期三 6月 2 11:30:00 2010 Copyright (c) 1982, 2005, Oracle. All rights reserved. 连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options PL/SQL 过程已成功完成。 从 Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options 断开
4、如果不带输出变量的较简单,如可以将exec_body.sql改成
exec myproc; --exec BATCH_DW_CTL(20100429); exit
这种形式即可。
5、然后,将批处理配在WINDOWS计划任务中,如是Shell则配在crontab里,实现定时调度。