[Home] [Help]
PACKAGE BODY: SYSTEM.AD_INST
Source
1 package body ad_inst as
2 /* $Header: adinstb.pls 120.0 2005/05/25 11:45:37 appldev noship $ */
3
4 --
5 -- PRIVATE VARIABLES
6 --
7
8 --
9 -- PRIVATE PROCEDURES/FUNCTIONS
10 --
11
12 --
13 -- PUBLIC PROCEDURES/FUNCTIONS
14 --
15
16 procedure compile_schema
17 (in_schema in varchar2)
18 is
19 success_with_comp_error exception;
20 PRAGMA EXCEPTION_INIT(success_with_comp_error, -24344);
21 -- compile packages first, then views, then bodies
22 -- this is because a view could reference a package header
23 cursor c1 is
24 select object_name, object_type from dba_objects
25 where owner = upper(compile_schema.in_schema)
26 and status = 'INVALID'
27 and object_type = 'PACKAGE';
28 cursor c2 is
29 select object_name, object_type from dba_objects
30 where owner = upper(compile_schema.in_schema)
31 and status = 'INVALID'
32 and object_type = 'VIEW';
33 cursor c3 is
34 select object_name, object_type from dba_objects
35 where owner = upper(compile_schema.in_schema)
36 and status = 'INVALID'
37 order by decode(object_type,'PACKAGE',1,'VIEW',2,'PACKAGE BODY',4,3);
38
39 begin
40 -- initialize error buffers
41 ad_inst.error_buf := null;
42 ad_apps_private.error_buf := null;
43
44 -- Check for APPS*DDL packages
45 ad_apps_private.check_for_apps_ddl(in_schema);
46
47 -- first compile all invalid packages specifications
48 for c1rec in c1 loop
49 -- for each invalid object compile
50 declare
51 statement varchar2(100);
52 begin
53 statement := 'ALTER PACKAGE "'||c1rec.object_name||
54 '" COMPILE SPECIFICATION';
55
56 do_apps_ddl(in_schema, statement);
57
58 exception
59 when success_with_comp_error then
60 --
61 -- Trap and ignore ORA-24344: success with compilation error
62 -- This only happens on ORACLE 8
63 --
64 -- reset error buffer
65 ad_inst.error_buf := null;
66 end;
67 end loop; -- loop over all invalid packages
68 -- next compile all invalid views
69 for c2rec in c2 loop
70 -- for each invalid object compile
71 declare
72 statement varchar2(100);
73 begin
74 statement := 'ALTER VIEW "'||c2rec.object_name||'" COMPILE';
75
76 do_apps_ddl(in_schema,statement);
77
78 exception
79 when success_with_comp_error then
80 --
81 -- Trap and ignore ORA-24344: success with compilation error
82 -- This only happens on ORACLE 8
83 --
84 -- reset error buffer
85 ad_inst.error_buf := null;
86 end;
87 end loop; -- loop over all invalid views
88 -- last, get all remaining invalid objects, which could be package bodies
89 -- unpackaged procedures or functions
90 for c3rec in c3 loop
91 -- for each invalid object compile
92 declare
93 statement varchar2(100);
94 begin
95 if c3rec.object_type = 'PACKAGE' then
96 statement := 'ALTER PACKAGE "'|| c3rec.object_name ||
97 '" COMPILE SPECIFICATION';
98 elsif c3rec.object_type = 'PACKAGE BODY' then
99 statement := 'ALTER PACKAGE "'|| c3rec.object_name ||
100 '" COMPILE BODY';
101 else
102 statement := 'ALTER '|| c3rec.object_type ||' "'||
103 c3rec.object_name || '" COMPILE';
104 end if;
105
106 do_apps_ddl(in_schema,statement);
107
108 exception
109 when success_with_comp_error then
110 --
111 -- Trap and ignore ORA-24344: success with compilation error
112 -- This only happens on ORACLE 8
113 --
114 -- reset error buffer
115 ad_inst.error_buf := null;
116 end;
117 end loop; -- loop over all remaining invalid objects
118
119 exception
120 when others then
121 ad_inst.error_buf := 'compile_schema('||in_schema||
122 '):'||ad_inst.error_buf||':'||ad_apps_private.error_buf;
123 raise;
124 end compile_schema;
125
126
127 procedure do_apps_ddl
128 (in_schema in varchar2,
129 ddl_text in varchar2)
130 is
131 c integer;
132 rows_processed integer;
133 statement varchar2(500);
134 begin
135 c := dbms_sql.open_cursor;
136 statement:='begin '||in_schema||'.apps_ddl.apps_ddl(:ddl_text); end;';
137 dbms_sql.parse(c, statement, dbms_sql.native);
138 dbms_sql.bind_variable(c,'ddl_text',ddl_text);
139 rows_processed := dbms_sql.execute(c);
140 dbms_sql.close_cursor(c);
141 exception
142 when others then
143 dbms_sql.close_cursor(c);
144 ad_inst.error_buf := 'do_apps_ddl('||in_schema||','||ddl_text||
145 '):'||ad_inst.error_buf;
146 raise;
147 end do_apps_ddl;
148
149
150 end ad_inst;