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