1 Package Body hxc_tkg_del as
2 /* $Header: hxctkgrhi.pkb 120.2 2005/09/23 05:28:58 rchennur noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hxc_tkg_del.'; -- Global package name
9 g_debug boolean := hr_utility.debug_enabled;
10 --
11 -- ----------------------------------------------------------------------------
12 -- |------------------------------< delete_dml >------------------------------|
13 -- ----------------------------------------------------------------------------
14 --
15 -- Description:
16 -- This procedure controls the actual dml delete logic. The functions of
17 -- this procedure are as follows:
18 -- 1) To set and unset the g_api_dml status as required (as we are about to
19 -- perform dml).
20 -- 2) To delete the specified row from the schema using the primary key in
21 -- the predicates.
22 -- 3) To trap any constraint violations that may have occurred.
23 -- 4) To raise any other errors.
24 --
25 -- Prerequisites:
26 -- This is an internal private procedure which must be called from the del
27 -- procedure.
28 --
29 -- In Parameters:
30 -- A Pl/Sql record structre.
31 --
32 -- Post Success:
33 -- The specified row will be delete from the schema.
34 --
35 -- Post Failure:
36 -- On the delete dml failure it is important to note that we always reset the
37 -- g_api_dml status to false.
38 -- If a child integrity constraint violation is raised the
39 -- constraint_error procedure will be called.
40 -- If any other error is reported, the error will be raised after the
41 -- g_api_dml status is reset.
42 --
43 -- Developer Implementation Notes:
44 -- None.
45 --
46 -- Access Status:
47 -- Internal Row Handler Use Only.
48 --
49 -- ----------------------------------------------------------------------------
50 Procedure delete_dml
51 (p_rec in hxc_tkg_shd.g_rec_type
52 ) is
53 --
54 l_proc varchar2(72) ;
55 --
56 Begin
57
58 if g_debug then
59 l_proc := g_package||'delete_dml';
60 hr_utility.set_location('Entering:'||l_proc, 5);
61 end if;
62 --
63 hxc_tkg_shd.g_api_dml := true; -- Set the api dml status
64
65 -- first of all delete any child rows
66
67 delete from hxc_tk_group_query_criteria tkgqc
68 where tkgqc.tk_group_query_id in
69 ( select tkgq.tk_group_query_id
70 from hxc_tk_group_queries tkgq
71 where tkgq.tk_group_id = p_rec.tk_group_id );
72
73 delete from hxc_tk_group_queries tkgq
74 where tkgq.tk_group_id = p_rec.tk_group_id;
75
76 -- Delete the hxc_tk_groups row.
77
78 delete from hxc_tk_groups tkg
79 where tkg.tk_group_id = p_rec.tk_group_id;
80 --
81 hxc_tkg_shd.g_api_dml := false; -- Unset the api dml status
82 --
83 if g_debug then
84 hr_utility.set_location(' Leaving:'||l_proc, 10);
85 end if;
86 --
87 Exception
88 When hr_api.child_integrity_violated then
89 -- Child integrity has been violated
90 hxc_tkg_shd.g_api_dml := false; -- Unset the api dml status
91 hxc_tkg_shd.constraint_error
92 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
93 When Others Then
94 hxc_tkg_shd.g_api_dml := false; -- Unset the api dml status
95 Raise;
96 End delete_dml;
97 --
98 -- ----------------------------------------------------------------------------
99 -- |------------------------------< pre_delete >------------------------------|
100 -- ----------------------------------------------------------------------------
101 --
102 -- Description:
103 -- This private procedure contains any processing which is required before
104 -- the delete dml.
105 --
106 -- Prerequisites:
107 -- This is an internal procedure which is called from the del procedure.
108 --
109 -- In Parameters:
110 -- A Pl/Sql record structre.
111 --
112 -- Post Success:
113 -- Processing continues.
114 --
115 -- Post Failure:
116 -- If an error has occurred, an error message and exception will be raised
117 -- but not handled.
118 --
119 -- Developer Implementation Notes:
120 -- Any pre-processing required before the delete dml is issued should be
121 -- coded within this procedure. It is important to note that any 3rd party
122 -- maintenance should be reviewed before placing in this procedure.
123 --
124 -- Access Status:
125 -- Internal Row Handler Use Only.
126 --
127 -- ----------------------------------------------------------------------------
128 Procedure pre_delete(p_rec in hxc_tkg_shd.g_rec_type) is
129 --
130 l_proc varchar2(72) ;
131 --
132 Begin
133
134 if g_debug then
135 l_proc := g_package||'pre_delete';
136 hr_utility.set_location('Entering:'||l_proc, 5);
137 hr_utility.set_location(' Leaving:'||l_proc, 10);
138 end if;
139 End pre_delete;
140 --
141 -- ----------------------------------------------------------------------------
142 -- |-----------------------------< post_delete >------------------------------|
143 -- ----------------------------------------------------------------------------
144 --
145 -- Description:
146 -- This private procedure contains any processing which is required after the
147 -- delete dml.
148 --
149 -- Prerequistes:
150 -- This is an internal procedure which is called from the del procedure.
151 --
152 -- In Parameters:
153 -- A Pl/Sql record structure.
154 --
155 -- Post Success:
156 -- Processing continues.
157 --
158 -- Post Failure:
159 -- If an error has occurred, an error message and exception will be raised
160 -- but not handled.
161 --
162 -- Developer Implementation Notes:
163 -- Any post-processing required after the delete dml is issued should be
164 -- coded within this procedure. It is important to note that any 3rd party
165 -- maintenance should be reviewed before placing in this procedure.
166 --
167 -- Access Status:
168 -- Internal Row Handler Use Only.
169 --
170 -- -----------------------------------------------------------------------------
171 Procedure post_delete(p_rec in hxc_tkg_shd.g_rec_type) is
172 --
173 l_proc varchar2(72) ;
174 --
175 Begin
176
177 if g_debug then
178 l_proc := g_package||'post_delete';
179 hr_utility.set_location('Entering:'||l_proc, 5);
180 end if;
181 begin
182 --
183 hxc_tkg_rkd.after_delete
184 (p_tk_group_id
185 => p_rec.tk_group_id
186 ,p_tk_group_name_o
187 => hxc_tkg_shd.g_old_rec.tk_group_name
188 ,p_tk_resource_id_o
189 => hxc_tkg_shd.g_old_rec.tk_resource_id
190 ,p_object_version_number_o
191 => hxc_tkg_shd.g_old_rec.object_version_number
192 );
193 --
194 exception
195 --
196 when hr_api.cannot_find_prog_unit then
197 --
198 hr_api.cannot_find_prog_unit_error
199 (p_module_name => 'HXC_TK_GROUP'
200 ,p_hook_type => 'AD');
201 --
202 end;
203 --
204 if g_debug then
205 hr_utility.set_location(' Leaving:'||l_proc, 10);
206 end if;
207 End post_delete;
208 --
209 -- ----------------------------------------------------------------------------
210 -- |---------------------------------< del >----------------------------------|
211 -- ----------------------------------------------------------------------------
212 Procedure del
213 (p_rec in hxc_tkg_shd.g_rec_type
214 ) is
215 --
216 l_proc varchar2(72) ;
217 --
218 Begin
219 g_debug :=hr_utility.debug_enabled;
220 if g_debug then
221 l_proc := g_package||'del';
222 hr_utility.set_location('Entering:'||l_proc, 5);
223 end if;
224 --
225 -- We must lock the row which we need to delete.
226 --
227 hxc_tkg_shd.lck
228 (p_rec.tk_group_id
229 ,p_rec.object_version_number
230 );
231 --
232 -- Call the supporting delete validate operation
233 --
234 hxc_tkg_bus.delete_validate(p_rec);
235 --
236 -- Call the supporting pre-delete operation
237 --
238 hxc_tkg_del.pre_delete(p_rec);
239 --
240 -- Delete the row.
241 --
242 hxc_tkg_del.delete_dml(p_rec);
243 --
244 -- Call the supporting post-delete operation
245 --
246 hxc_tkg_del.post_delete(p_rec);
247 --
248 End del;
249 --
250 -- ----------------------------------------------------------------------------
251 -- |---------------------------------< del >----------------------------------|
252 -- ----------------------------------------------------------------------------
253 Procedure del
254 (p_tk_group_id in number
255 ,p_object_version_number in number
256 ) is
257 --
258 l_rec hxc_tkg_shd.g_rec_type;
259 l_proc varchar2(72) ;
260 --
261 Begin
262 g_debug :=hr_utility.debug_enabled;
263 if g_debug then
264 l_proc := g_package||'del';
265 hr_utility.set_location('Entering:'||l_proc, 5);
266 end if;
267 --
268 -- As the delete procedure accepts a plsql record structure we do need to
269 -- convert the arguments into the record structure.
270 -- We don't need to call the supplied conversion argument routine as we
271 -- only need a few attributes.
272 --
273 l_rec.tk_group_id := p_tk_group_id;
274 l_rec.object_version_number := p_object_version_number;
275 --
276 -- Having converted the arguments into the hxc_tkg_rec
277 -- plsql record structure we must call the corresponding entity
278 -- business process
279 --
280 hxc_tkg_del.del(l_rec);
281 --
282 if g_debug then
283 hr_utility.set_location(' Leaving:'||l_proc, 10);
284 end if;
285 End del;
286 --
287 end hxc_tkg_del;