DBA Data[Home] [Help]

PACKAGE BODY: APPS.DELETE_FROM_IREP

Source


1 package body DELETE_FROM_IREP as
2   /* $Header: DELFRMIREPB.pls 120.0.12020000.4 2012/07/16 05:32:08 snalagan noship $ */
3 
4   procedure delete_irep_entry( key_id in NUMBER) is
5 
6 	assoc_key_id NUMBER(15);
7 	stable VARCHAR2(16);
8 	filename VARCHAR2(36);
9 	fileproduct VARCHAR2(8);
10 	fileversion VARCHAR2(150);
11 	ildtfilename VARCHAR2(150);
12    begin
13 	--fetch source table
14 	select src_table
15 	into stable
16 	from FND_IREP_ALL_INTERFACES
17 	where class_id = key_id;
18 
19 
20 	if (stable = 'FND_IREP_CLASSES') then
21 		-- find file name and update history table
22 
23 		select source_file_name, source_file_product, source_file_version
24 		into filename, fileproduct, fileversion
25 		from fnd_irep_classes
26 		where class_id = key_id;
27 
28 		ildtfilename  := replace(filename,'.','_');
29 		ildtfilename  := ildtfilename || '.ildt';
30 
31 		begin
32 			update fnd_irep_deferred_load_files
33 			set load_status = 'N'
34 			where file_name = ildtfilename
35 			and fileproduct = file_product
36 			and fileversion = file_version;
37 		exception
38 		when others then
39 			if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
40 				FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'DeleteFromIrep', 'Error: History table does not have this entry.');
41 			end if;
42 		end;
43 
44 
45 		-- remove class subentities (except methods)
46 
47 		Delete from FND_IREP_CLASS_DATASOURCES
48 		where CLASS_ID = key_id;
49 
50 
51 		Delete from FND_IREP_CLASS_PARENT_ASSIGNS
52 		where class_name in
53 			(select class_name
54 			from fnd_irep_classes
55 			where class_id = key_id);
56 
57 		Delete from FND_LOOKUP_ASSIGNMENTS
58 		where obj_name = 'FND_IREP_CLASSES'
59 		  and INSTANCE_PK1_VALUE = to_char(key_id);
60 
61 		Delete from FND_CHILD_ANNOTATIONS
62 		where parent_id = key_id
63 		  and parent_flag = 'C';
64 
65 		Delete from FND_IREP_USES_TABLES
66 		where CLASS_ID = key_id;
67 
68 		Delete from FND_IREP_USES_MAPS
69 		where CLASS_ID = key_id;
70 
71 		if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
72 				FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'DeleteFromIrep', 'Class Sub-Entities Removed');
73 		end if;
74 
75 		-- remove method subentities
76 		Delete from FND_LOOKUP_ASSIGNMENTS
77 		where obj_name = 'FND_IREP_FUNCTION_FLAVORS'
78 		  and INSTANCE_PK1_VALUE in
79 			(select function_id
80 			   from FND_FORM_FUNCTIONS
81 			  where irep_class_id = key_id);
82 
83 		Delete from FND_CHILD_ANNOTATIONS
84 		where parent_flag = 'F'
85 		  and parent_id in
86 			(select function_id
87 			   from FND_FORM_FUNCTIONS
88 			  where irep_class_id = key_id);
89 
90 		Delete from FND_PARAMETERS
91 		where function_id in
92 			(select function_id
93 			   from FND_FORM_FUNCTIONS
94 			  where irep_class_id = key_id);
95 
96 		if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
97 				FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'DeleteFromIrep', 'Function Sub-Entities Removed');
98 		end if;
99 
100 
101 		-- ### remove derived entries ###
102 		begin
103 			--fetch derived entry
104 			select class_id
105 			into assoc_key_id
106 			from FND_IREP_ALL_INTERFACES
107 			where assoc_class_id  = key_id;
108 
109 			if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
110 				FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'DeleteFromIrep', 'Derived Entry : '|| assoc_key_id);
111 			end if;
112 
113 			-- remove flavors
114 			Delete from FND_IREP_FUNCTION_FLAVORS
115 			where FUNCTION_ID in
116 				(select function_id
117 				from FND_FORM_FUNCTIONS
118 				where irep_class_id = assoc_key_id);
119 
120 			if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
121 				FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'DeleteFromIrep', 'Derived Function Flavors Removed');
122 			end if;
123 
124 			--remove functions
125 			Delete from FND_FORM_FUNCTIONS_TL
126 			where function_id in
127 				(select function_id
128 				from fnd_form_functions
129 				where irep_class_id = assoc_key_id);
130 
131 			Delete from FND_FORM_FUNCTIONS
132 			where irep_class_id  = assoc_key_id;
133 
134 			if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
135 				FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'DeleteFromIrep', 'Derived Functions Removed');
136 			end if;
137 
138 			-- remove classes
139 			Delete from FND_IREP_CLASSES_TL
140 			where class_id = assoc_key_id;
141 
142 			Delete from FND_IREP_CLASSES
143 			where class_id = assoc_key_id;
144 
145 			if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
146 				FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'DeleteFromIrep', 'Derived Classes Removed');
147 			end if;
148 
149 		exception
150 		when others then
151 			if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
152 				FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'DeleteFromIrep', 'Derived Entries Not Present.');
153 			end if;
154 		end;
155 
156 
157 		-- ### remove basic entries ###
158 
159 		-- remove flavors
160 		Delete from FND_IREP_FUNCTION_FLAVORS
161 		where FUNCTION_ID in
162 			(select function_id
163 			from FND_FORM_FUNCTIONS
164 			where irep_class_id = key_id);
165 
166 		if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
167 				FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'DeleteFromIrep', 'Function Flavors Removed');
168 		end if;
169 
170 		--remove functions
171 		Delete from FND_FORM_FUNCTIONS_TL
172 		where function_id in
173 			(select function_id
174 			from fnd_form_functions
175 			where irep_class_id = key_id);
176 
177 		Delete from FND_FORM_FUNCTIONS
178 		where irep_class_id  = key_id;
179 
180 		if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
181 				FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'DeleteFromIrep', 'Functions Removed');
182 		end if;
183 
184 		-- remove classes
185 		Delete from FND_IREP_CLASSES_TL
186 		where class_id = key_id;
187 
188 		Delete from FND_IREP_CLASSES
189 		where class_id = key_id;
190 
191 		if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
192 				FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'DeleteFromIrep','Classes Removed. ' || 'Deletion completed for all entries corresponding to Class Id : '|| key_id );
193 		end if;
194 
195 
196 	else
197 		-- remove object subentities
198 		Delete from FND_OBJECT_KEY_SETS
199 		where object_id = key_id;
200 
201 		Delete from FND_LOOKUP_ASSIGNMENTS
202 		where obj_name = 'FND_OBJECTS'
203 		and INSTANCE_PK1_VALUE = to_char(key_id);
204 
205 		Delete from FND_CHILD_ANNOTATIONS
206 		where parent_id = key_id
207 		and parent_flag = 'O';
208 
209 		Delete from FND_OBJECT_TYPE_MEMBERS
210 		where object_id = key_id;
211 
212 		if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
213 				FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'DeleteFromIrep', 'Object Sub-Entities Removed');
214 		end if;
215 
216 
217 		-- remove objects
218 		Delete from FND_OBJECTS_TL
219 		where object_id = key_id;
220 
221 		Delete from FND_OBJECTS
222 		where object_id  = key_id;
223 
224 		if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
225 				FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'DeleteFromIrep', 'Objects Removed . '|| 'Deletion completed for all entries corresponding to object Id : '|| key_id);
226 		end if;
227 
228 
229 	end if;
230   commit;
231   exception
232 
233   when others then
234 
235    if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) then
236 	FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, 'DeleteFromIrep', SQLERRM);
237    end if;
238 
239 --  end;
240    end delete_irep_entry ;
241 
242 end DELETE_FROM_IREP;
243