经常碰到因为过程或者视图没有被编译,,而无法正常运行基于存储过程的数据库程序。 用以下几句sql语句,用于在程序执行之前,自动编译。省去了我们的麻烦
/***************************************pro.sql****************************************/ #用于快速编辑过程 set feedback off set heading off spool c:\pro.sql; #编译过程 select 'alter procedure 'OBJECT_NAME' compile;' from sys.all_probe_objects where OWNER='UserName' and OBJECT_TYPE='PROCEDURE' and STATUS='INVALID'; spool off; @c:\pro.sql; #编译视图 spool c:\pro.sql; select 'alter view 'OBJECT_NAME' compile;' from sys.all_probe_objects where OWNER='UserName' and OBJECT_TYPE='view' and STATUS='INVALID'; spool off; @c:\pro.sql; exit;
#select * from sys.all_objects where object_type in ('TABLE', 'VIEW' ) and STATUS!='VALID';
/**************************************************pro.bat ******************************************************/ set Oracle_SID=DB_NAME; sqlplus username/passWord @F:\shell\pro.sql 用于执行,这个sql语句
/*
/**************************************************exec.bat*****************************************************/ 加入at 计划任务 net stop schedule net start schedule at 23:00 /every:M,T,W,Th,F,S,SU F:\shell\pro.bat
////////////////////////////////////////////////////////////////////The End ///////////////////////////////////////////////////////////////////////////////////
|