如何重新编译包

上一篇 / 下一篇  2008-11-22 17:49:37 / 个人分类:Oracle

  • 文件版本: V1.0
  • 开发商: 本站原创
  • 文件来源: 本地
  • 界面语言: 简体中文
  • 授权方式: 免费
  • 运行平台: Win9X/Win2000/WinXP
51Testing软件测试网.a `+f `"B V2Sf"}?

我写了一个:   51Testing软件测试网uSy9j/j!K9`#pyp
  CREATE   OR   REPLACE   PROCEDURE   compile_invalid_procedure  
;M1R7b+X$tT0  IS  
M bi Cvk8FIb0      CURSOR   c1   IS    
(B z;e1\ h$^0          SELECT     owner,object_name,object_type   51Testing软件测试网4Ge1qgZ6N
              FROM   dba_objects     51Testing软件测试网4A/MK1||@d2`
            WHERE   object_type   IN   ('FUNCTION','PROCEDURE')   51Testing软件测试网2R |XW,z(?5i[c
                AND   status='INVALID';  
L!`(ARw&UL0      l_c1   c1%ROWTYPE;             51Testing软件测试网Agq3Pj;I%j/V
      str1   VARCHAR2(100);   51Testing软件测试网)Z'bK#W6xA9Q
  BEGIN   51Testing软件测试网6N2\,`VC8F2Xe
      OPEN   c1   51Testing软件测试网;H~f.m&EKh
      LOOP    
^ J!UK,y2e;^{?0          FETCH   c1   INTO   TO   l_c1;   51Testing软件测试网:TuC)W}J
          EXIT   WHEN   c1%NOTFOUND;   51Testing软件测试网c F8~Zu
          str1:='alter   '||l_c1.object_type||'   '||l_c1.owner||'.'||l_c1.object_name||'   compile';   51Testing软件测试网C.?F+R0V+TC
          dbms_utility.exec_ddl_statement(str1);  
#E1_ P9I#r2{kv0      END   LOOP;   51Testing软件测试网sQ5Y%n/G
      CLOSE   c1;  
;VS;HW0h0  END;51Testing软件测试网%c"JN)M*uT!Xm'a*^

51Testing软件测试网Qo V:|^N]

这个过程有什么好写的,oracle中有现成的,为什么不用?!   51Testing软件测试网\^mu;\
  sys用户下的dbms_utility.compile_schema。  
P*u(xE j`0  详细说明如下:  
Z @-[#g0o0  procedure   compile_schema(schema   varchar2,   compile_all   boolean   default   TRUE);   51Testing软件测试网'[ZO6Q?&v_
      --     Compile   all   procedures,   functions,   packages   and   triggers   in   the   specified  
qms8A9L3@s:n C h#}6r0      --     schema.     After   calling   this   procedure   you   should   select   from   view   51Testing软件测试网#f.x1Fh qhu
      --     ALL_OBJECTS   for   items   with   status   of   'INVALID'   to   see   if   all   objects   51Testing软件测试网!Ix b_3} U9z
      --     were   successfully   compiled.     You   may   use   the   command   "SHOW   ERRORS   51Testing软件测试网$K \vj0cZ'A2b
      --     <type>   <schema>.<name>"   to   see   the   errors   assocated   with   'INVALID'  
H-^tx}0      --     objects.  
1sFI}lUb$zU0      --     Input   arguments:  
-b L W.M(m)ud0      --         schema   51Testing软件测试网 W)Fo)M5RM#k
      --             Name   of   the   schema.   51Testing软件测试网x$x;j*ca9]9[U3K#k
      --         compile_all  
m-zv{}3s z3A0      --             This   is   a   boolean   flag   that   indicates   whether   we   should   compile   all  
!`rVu2ckZ-\ AZ0      --             schema   objects   or   not,   regardless   of   whether   the   object   is   currently   51Testing软件测试网VuU,a `
      --             flagged   as   valid   or   not.   The   default   is   to   support   the   previous   51Testing软件测试网g D g#x)B?E sF
      --             compile_schema()   behaviour   and   compile   ALL   objects.       51Testing软件测试网|L1}:Zm9X
      --     Exceptions:  
g8oCC g*w0      --         ORA-20000:   Insufficient   privileges   for   some   object   in   this   schema.  
2a3M6O&v0x{7j,S;\0      --         ORA-20001:   Cannot   recompile   SYS   objects.  
W x(aYpLng0      --         ORA-20002:   Maximum   iterations   exceeded.    
Ot7}%X!G U4g1e+X0      --                               Some   objects   may   not   have   been   recompiled   51Testing软件测试网7rT8d'V6A"| e!G ^2p
      --     Notes:   51Testing软件测试网"UH0}"t:dO
      --       1)   When   this   procedure   is   executed   it   determines   an   upper   limit   to  
?S1H[ Zte0      --             the   number   of   objects   that   need   to   be   recompiled   and   then   iterates  
1S*oVX"?,x!~0      --             around   the   objects   to   be   recompiled.   Should   this   upper   limit   be  
p sY&XH0      --             exceeded   then   the   last   exception   will   be   raised   and   in   this   case   51Testing软件测试网/v#n`zQ_(h n w {
      --             you   can   just   re-execute   the   procedure   again.   Should   this   fail   with  
kvip:^#Q&w0      --             the   same   error   then   this   may   indicate   an   object   that   persistently  
"v@X`;f0      --             fails   for   some   reason.

dRt(BB+Zkyx1nOu0

#Uf6]c&_{8g9Z0 51Testing软件测试网8aUGl6r

wE-Y ~e Gn0set echo off pagesize 0 feedback off51Testing软件测试网sk%Oyy(vR%R

51Testing软件测试网E-G+j7x$@d,~

define v_input_un       = &151Testing软件测试网'[8_?(eSb
define v_input_pw       = &251Testing软件测试网`|(EKi:L5R
define v_input_conn_str = &3

a$b2Li^E0

[i.[r"e0connect &v_input_un/&v_input_pw@&v_input_conn_str51Testing软件测试网n/Q k"N&S:V ax

8k,Eh ~}5ZT7c@0define v_compile_command_file = ./log/compile_&v_input_un..sql51Testing软件测试网wx;@5mus{
define v_compile_log_file     = ./log/compile_&v_input_un..log

D zI|k'^t;E0 51Testing软件测试网8I%@1@X%E:J qu

spool &v_compile_command_file51Testing软件测试网;g GE?a+w4?o;BAb5R8[
prompt spool &v_compile_log_file51Testing软件测试网C6dH3U$`4@L,T
prompt show user51Testing软件测试网%IC?!E4~O ze
prompt set echo on feedback on

6\ ?`+G&Buq4R!k"rJ0

z Enx `#[xN0select   'alter ' || o.object_type ||  ' "'
#r!pIZ.uV2wy_0         || o.object_name || '" compile;'51Testing软件测试网yz z Qd)P\0k
from     user_objects o
G:j:BWc.g.j0where    o.object_type not like '% BODY'
#j:g@ r#S%OWo0and      o.object_type not in ('UNDEFINED', 'JAVA CLASS')51Testing软件测试网\!Y6o$h$sE
and      o.status = 'INVALID'51Testing软件测试网'D.Q:H0\7D ]:m
order by decode(o.object_type
{j r C0Km4tKgP0              , 'VIEW',      151Testing软件测试网,qn0U} @7S f
              , 'TYPE',      251Testing软件测试网0j1cL\ I q#I%Lr8h| r
              , 'FUNCTION',  3
+f|"R ];B%?z[o0              , 'PROCEDURE', 451Testing软件测试网r? g{3X
              , 'PACKAGE',   5
f^e(i$Hh:eV*p3t'L0              , 999)51Testing软件测试网 b!|Qq5Ae5q
       , o.object_name
7m\Lp'nJP0/51Testing软件测试网0p'yf c G/d G/m

51Testing软件测试网 Pn$l)B"S*vi X

select   'alter ' ||
(tt&Ibds(y lW0         substr(o.object_type, 1, instr(o.object_type, ' ') - 1)51Testing软件测试网C8B}0F8_3X#Ya
         ||  ' "'51Testing软件测试网-N+O4`YR2^&U VR
         || o.object_name || '" compile body;'
Q {s*? i\t~nv0from     user_objects o51Testing软件测试网p4M}:OQ ]
where    o.object_type like '% BODY'
,ou/rUxD4j0and      o.object_type not in ('UNDEFINED', 'JAVA CLASS')51Testing软件测试网_3Po,I1u5@8W
and      o.status = 'INVALID'51Testing软件测试网%J%]U8m s|?)q0W
order by decode(o.object_type
Ab\6L"~4ja7ERD.@0              , 'VIEW',      1
Q7]HV(r2w6H*K0              , 'TYPE',      2
f1z:J:P v0              , 'FUNCTION',  351Testing软件测试网E.gf0|0t
              , 'PROCEDURE', 4
.W,q&Z,{u@K1LN0              , 'PACKAGE',   5
;D0M'cQ/WG:cPF[3Z0              , 999)51Testing软件测试网 ~&n'NRa*lO9f
       , o.object_name51Testing软件测试网B3`S(u O m7U
/

j7wOH9DC0 51Testing软件测试网 F }rO+_~}~

prompt spool off
1^;q8v'J-J(R-H-R QQ0spool off

q%a5K@ i9b g@v J0 51Testing软件测试网#b a"{ZDe

@&v_compile_command_file51Testing软件测试网*j%Zi#N;L/z3KpU[
51Testing软件测试网A)tkH{%}Ti

TAG: Oracle

 

评分:0

我来说两句

Open Toolbar