forked from xtender/xt_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile_invalids.sql
50 lines (46 loc) · 1.3 KB
/
compile_invalids.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
col object_type format a20;
accept _owner prompt "Enter owner mask[%]: ";
accept _otype prompt "Enter type mask[%]: ";
accept _oname prompt "Enter name mask[%]: ";
set echo on feed on serverout on
declare
procedure p_exec(cmd varchar2) is
begin
execute immediate cmd;
dbms_output.put_line('Success: '||cmd);
exception when others then
dbms_output.put_line('Error: '||cmd||': '||translate(sqlerrm,chr(10),' '));
end;
begin
for r in (
select
owner
,object_type
,object_name
,status
,o.timestamp
from dba_objects o
where o.owner like nvl(upper('&_owner'),'%')
and object_type like nvl(upper('&_otype'),'%')
and object_name like nvl(upper('&_oname'),'%')
and o.status='INVALID'
)
loop
p_exec('alter '||r.object_type||' "'||r.owner||'"."'||r.object_name||'" compile');
end loop;
end;
/
select
owner
,object_type
,object_name
,status
,o.timestamp
from dba_objects o
where o.owner like nvl(upper('&_owner'),'%')
and object_type like nvl(upper('&_otype'),'%')
and object_name like nvl(upper('&_oname'),'%')
and o.status='INVALID';
col object_type clear;
undef _owner _otype _oname;
set echo off feed off serverout off