1 Package Body ame_atu_del as
2 /* $Header: amaturhi.pkb 120.6 2006/02/15 04:04 prasashe noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ame_atu_del.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |----------------------------< dt_delete_dml >-----------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 -- This procedure controls the actual dml delete logic for the datetrack
17 -- delete modes: ZAP, DELETE, FUTURE_CHANGE and DELETE_NEXT_CHANGE. The
18 -- execution is 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) If the delete mode is DELETE_NEXT_CHANGE then delete where the
22 -- effective start date is equal to the validation start date.
23 -- 3) If the delete mode is not DELETE_NEXT_CHANGE then delete
24 -- all rows for the entity where the effective start date is greater
25 -- than or equal to the validation start date.
26 -- 4) To raise any errors.
27 --
28 -- Prerequisites:
29 -- This is an internal private procedure which must be called from the
30 -- delete_dml procedure.
31 --
32 -- In Parameters:
33 -- A Pl/Sql record structure.
34 --
35 -- Post Success:
36 -- The specified row will be delete from the schema.
37 --
38 -- Post Failure:
39 -- On the delete dml failure it is important to note that we always reset the
40 -- g_api_dml status to false.
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 -- This is an internal private procedure which must be called from the
46 -- delete_dml procedure.
47 --
48 -- Access Status:
49 -- Internal Row Handler Use Only.
50 --
51 -- {End Of Comments}
52 -- ----------------------------------------------------------------------------
53 Procedure dt_delete_dml
54 (p_rec in out nocopy ame_atu_shd.g_rec_type
55 ,p_effective_date in date
56 ,p_datetrack_mode in varchar2
57 ,p_validation_start_date in date
58 ,p_validation_end_date in date
59 ) is
60 --
61 l_proc varchar2(72) := g_package||'dt_delete_dml';
62 --
63 Begin
64 hr_utility.set_location('Entering:'||l_proc, 5);
65 If (p_datetrack_mode = hr_api.g_delete_next_change) then
66 --
67 --
68 -- Delete the where the effective start date is equal
69 -- to the validation end date.
70 --
71 delete from ame_attribute_usages
72 where attribute_id = p_rec.attribute_id
73 and application_id = p_rec.application_id
74 and start_date = p_validation_start_date;
75 --
76 --
77 /*Else
78 --
79 --
80 -- Delete the row(s) where the effective start date is greater than
81 -- or equal to the validation start date.
82 --
83 delete from ame_attribute_usages
84 where attribute_id = p_rec.attribute_id
85 and application_id = p_rec.application_id
86 and start_date >= p_validation_start_date;*/
87 --
88 --
89 End If;
90 --
91 hr_utility.set_location(' Leaving:'||l_proc, 20);
92 --
93 End dt_delete_dml;
94 --
95 -- ----------------------------------------------------------------------------
96 -- |------------------------------< delete_dml >------------------------------|
97 -- ----------------------------------------------------------------------------
98 Procedure delete_dml
99 (p_rec in out nocopy ame_atu_shd.g_rec_type
100 ,p_effective_date in date
101 ,p_datetrack_mode in varchar2
102 ,p_validation_start_date in date
103 ,p_validation_end_date in date
104 ) is
105 --
106 l_proc varchar2(72) := g_package||'delete_dml';
107 --
108 Begin
109 hr_utility.set_location('Entering:'||l_proc, 5);
110 --
111 ame_atu_del.dt_delete_dml
112 (p_rec => p_rec
113 ,p_effective_date => p_effective_date
114 ,p_datetrack_mode => p_datetrack_mode
115 ,p_validation_start_date => p_validation_start_date
116 ,p_validation_end_date => p_validation_end_date
117 );
118 --
119 hr_utility.set_location(' Leaving:'||l_proc, 10);
120 End delete_dml;
121 --
122 -- ----------------------------------------------------------------------------
123 -- |----------------------------< dt_pre_delete >-----------------------------|
124 -- ----------------------------------------------------------------------------
125 -- {Start Of Comments}
126 --
127 -- Description:
128 -- The dt_pre_delete process controls the execution of dml
129 -- for the datetrack modes: DELETE, FUTURE_CHANGE
130 -- and DELETE_NEXT_CHANGE only.
131 --
132 -- Prerequisites:
133 -- This is an internal procedure which is called from the pre_delete
134 -- procedure.
135 --
136 -- In Parameters:
137 -- A Pl/Sql record structure.
138 --
139 -- Post Success:
140 -- Processing continues.
141 --
142 -- Post Failure:
143 -- If an error has occurred, an error message and exception will be raised
144 -- but not handled.
145 --
146 -- Developer Implementation Notes:
147 -- This is an internal procedure which is required by Datetrack. Don't
148 -- remove or modify.
149 --
150 -- Access Status:
151 -- Internal Row Handler Use Only.
152 --
153 -- {End Of Comments}
154 -- ----------------------------------------------------------------------------
155 Procedure dt_pre_delete
156 (p_rec in out nocopy ame_atu_shd.g_rec_type
157 ,p_effective_date in date
158 ,p_datetrack_mode in varchar2
159 ,p_validation_start_date in date
160 ,p_validation_end_date in date
161 ) is
162 --
163 l_proc varchar2(72) := g_package||'dt_pre_delete';
164 --
165 Begin
166 hr_utility.set_location('Entering:'||l_proc, 5);
167 --
168 If (p_datetrack_mode <> hr_api.g_zap) then
169 --
170 p_rec.start_date
171 := ame_atu_shd.g_old_rec.start_date;
172 --
173 If (p_datetrack_mode = hr_api.g_delete) then
174 p_rec.end_date := p_validation_start_date;
175 Else
176 p_rec.end_date := p_validation_end_date;
177 End If;
178 --
179 -- Update the current effective end date record
180 --
181 ame_atu_shd.upd_end_date
182 (p_effective_date => p_effective_date
183 ,p_attribute_id => p_rec.attribute_id
184 ,p_application_id => p_rec.application_id
185 ,p_new_end_date => p_rec.end_date
186 ,p_object_version_number => p_rec.object_version_number
187 );
188 Else
189 p_rec.start_date := null;
190 p_rec.end_date := null;
191 End If;
192 hr_utility.set_location(' Leaving:'||l_proc, 10);
193 End dt_pre_delete;
194 --
195 -- ----------------------------------------------------------------------------
196 -- |------------------------------< pre_delete >------------------------------|
197 -- ----------------------------------------------------------------------------
198 -- {Start Of Comments}
199 --
200 -- Description:
201 -- This private procedure contains any processing which is required before
202 -- the delete dml.
203 --
204 -- Prerequisites:
205 -- This is an internal procedure which is called from the del procedure.
206 --
207 -- In Parameters:
208 -- A Pl/Sql record structure.
209 --
210 -- Post Success:
211 -- Processing continues.
212 --
213 -- Post Failure:
214 -- If an error has occurred, an error message and exception will be raised
215 -- but not handled.
216 --
217 -- Developer Implementation Notes:
218 -- Any pre-processing required before the delete dml is issued should be
219 -- coded within this procedure. It is important to note that any 3rd party
220 -- maintenance should be reviewed before placing in this procedure. The call
221 -- to the dt_delete_dml procedure should NOT be removed.
222 --
223 -- Access Status:
224 -- Internal Row Handler Use Only.
225 --
226 -- {End Of Comments}
227 -- ----------------------------------------------------------------------------
228 Procedure pre_delete
229 (p_rec in out nocopy ame_atu_shd.g_rec_type
230 ,p_effective_date in date
231 ,p_datetrack_mode in varchar2
232 ,p_validation_start_date in date
233 ,p_validation_end_date in date
234 ) is
235 --
236 l_proc varchar2(72) := g_package||'pre_delete';
237 --
238 --
239 --
240 Begin
241 hr_utility.set_location('Entering:'||l_proc, 5);
242 --
243 --
244 --
245 ame_atu_del.dt_pre_delete
246 (p_rec => p_rec
247 ,p_effective_date => p_effective_date
248 ,p_datetrack_mode => p_datetrack_mode
249 ,p_validation_start_date => p_validation_start_date
250 ,p_validation_end_date => p_validation_end_date
251 );
252 --
253 hr_utility.set_location(' Leaving:'||l_proc, 10);
254 End pre_delete;
255 --
256 -- ----------------------------------------------------------------------------
257 -- |----------------------------< post_delete >-------------------------------|
258 -- ----------------------------------------------------------------------------
259 -- {Start Of Comments}
260 --
261 -- Description:
262 -- This private procedure contains any processing which is required after
263 -- the delete dml.
264 --
265 -- Prerequisites:
266 -- This is an internal procedure which is called from the del procedure.
267 --
268 -- In Parameters:
269 -- A Pl/Sql record structure.
270 --
271 -- Post Success:
272 -- Processing continues.
273 --
274 -- Post Failure:
275 -- If an error has occurred, an error message and exception will be raised
276 -- but not handled.
277 --
278 -- Developer Implementation Notes:
279 -- Any post-processing required after the delete dml is issued should be
280 -- coded within this procedure. It is important to note that any 3rd party
281 -- maintenance should be reviewed before placing in this procedure.
282 --
283 -- Access Status:
284 -- Internal Row Handler Use Only.
285 --
286 -- {End Of Comments}
287 -- ----------------------------------------------------------------------------
288 Procedure post_delete
289 (p_rec in ame_atu_shd.g_rec_type
290 ,p_effective_date in date
291 ,p_datetrack_mode in varchar2
292 ,p_validation_start_date in date
293 ,p_validation_end_date in date
294 ) is
295 --
296 l_proc varchar2(72) := g_package||'post_delete';
297 --
298 Begin
299 hr_utility.set_location('Entering:'||l_proc, 5);
300 begin
301 --
302 ame_atu_rkd.after_delete
303 (p_effective_date
304 => p_effective_date
305 ,p_datetrack_mode
306 => p_datetrack_mode
307 ,p_validation_start_date
308 => p_validation_start_date
309 ,p_validation_end_date
310 => p_validation_end_date
311 ,p_attribute_id
312 => p_rec.attribute_id
313 ,p_application_id
314 => p_rec.application_id
315 ,p_start_date
316 => p_rec.start_date
317 ,p_end_date
318 => p_rec.end_date
319 ,p_query_string_o
320 => ame_atu_shd.g_old_rec.query_string
321 ,p_use_count_o
322 => ame_atu_shd.g_old_rec.use_count
323 ,p_user_editable_o
324 => ame_atu_shd.g_old_rec.user_editable
325 ,p_is_static_o
326 => ame_atu_shd.g_old_rec.is_static
327 ,p_start_date_o
328 => ame_atu_shd.g_old_rec.start_date
329 ,p_end_date_o
330 => ame_atu_shd.g_old_rec.end_date
331 ,p_security_group_id_o
332 => ame_atu_shd.g_old_rec.security_group_id
333 ,p_value_set_id_o
334 => ame_atu_shd.g_old_rec.value_set_id
335 ,p_object_version_number_o
339 exception
336 => ame_atu_shd.g_old_rec.object_version_number
337 );
338 --
340 --
341 when hr_api.cannot_find_prog_unit then
342 --
343 hr_api.cannot_find_prog_unit_error
344 (p_module_name => 'AME_ATTRIBUTE_USAGES'
345 ,p_hook_type => 'AD');
346 --
347 end;
348 --
349 hr_utility.set_location(' Leaving:'||l_proc, 10);
350 End post_delete;
351 --
352 -- ----------------------------------------------------------------------------
353 -- |---------------------------------< del >----------------------------------|
354 -- ----------------------------------------------------------------------------
355 Procedure del
356 (p_effective_date in date
357 ,p_datetrack_mode in varchar2
358 ,p_rec in out nocopy ame_atu_shd.g_rec_type
359 ) is
360 --
361 l_proc varchar2(72) := g_package||'del';
365 Begin
362 l_validation_start_date date;
363 l_validation_end_date date;
364 --
366 hr_utility.set_location('Entering:'||l_proc, 5);
367 --
368 -- Ensure that the DateTrack delete mode is valid
369 --
370 dt_api.validate_dt_del_mode(p_datetrack_mode => p_datetrack_mode);
371 --
372 -- We must lock the row which we need to delete.
373 --
374 ame_atu_shd.lck
375 (p_effective_date => p_effective_date
376 ,p_datetrack_mode => p_datetrack_mode
377 ,p_attribute_id => p_rec.attribute_id
378 ,p_application_id => p_rec.application_id
379 ,p_object_version_number => p_rec.object_version_number
380 ,p_validation_start_date => l_validation_start_date
381 ,p_validation_end_date => l_validation_end_date
382 );
383 --
384 -- Call the supporting delete validate operation
385 --
386 ame_atu_bus.delete_validate
387 (p_rec => p_rec
388 ,p_effective_date => p_effective_date
389 ,p_datetrack_mode => p_datetrack_mode
390 ,p_validation_start_date => l_validation_start_date
391 ,p_validation_end_date => l_validation_end_date
392 );
393 --
394 -- Call to raise any errors on multi-message list
395 hr_multi_message.end_validation_set;
396 --
397 -- Call the supporting pre-delete operation
398 --
399 ame_atu_del.pre_delete
400 (p_rec => p_rec
401 ,p_effective_date => p_effective_date
402 ,p_datetrack_mode => p_datetrack_mode
406 --
403 ,p_validation_start_date => l_validation_start_date
404 ,p_validation_end_date => l_validation_end_date
405 );
407 -- Delete the row.
408 --
409 ame_atu_del.delete_dml
410 (p_rec => p_rec
411 ,p_effective_date => p_effective_date
412 ,p_datetrack_mode => p_datetrack_mode
413 ,p_validation_start_date => l_validation_start_date
414 ,p_validation_end_date => l_validation_end_date
415 );
416 -- Call the supporting post-delete operation
417 --
418 ame_atu_del.post_delete
419 (p_rec => p_rec
420 ,p_effective_date => p_effective_date
421 ,p_datetrack_mode => p_datetrack_mode
422 ,p_validation_start_date => l_validation_start_date
423 ,p_validation_end_date => l_validation_end_date
424 );
425 --
426 -- Call to raise any errors on multi-message list
427 hr_multi_message.end_validation_set;
428 --
429 hr_utility.set_location(' Leaving:'||l_proc, 5);
430 End del;
431 --
432 -- ----------------------------------------------------------------------------
433 -- |--------------------------------< del >-----------------------------------|
434 -- ----------------------------------------------------------------------------
435 Procedure del
436 (p_effective_date in date
437 ,p_datetrack_mode in varchar2
438 ,p_attribute_id in number
439 ,p_application_id in number
440 ,p_object_version_number in out nocopy number
441 ,p_start_date out nocopy date
442 ,p_end_date out nocopy date
443 ) is
444 --
445 l_rec ame_atu_shd.g_rec_type;
446 l_proc varchar2(72) := g_package||'del';
447 --
448 Begin
449 hr_utility.set_location('Entering:'||l_proc, 5);
450 --
451 -- As the delete procedure accepts a plsql record structure we do need to
452 -- convert the arguments into the record structure.
453 -- We don't need to call the supplied conversion argument routine as we
454 -- only need a few attributes.
455 --
456 l_rec.attribute_id := p_attribute_id;
457 l_rec.application_id := p_application_id;
458 l_rec.start_date := p_start_date;
459 l_rec.end_date := p_end_date;
460 l_rec.object_version_number := p_object_version_number;
461 --
462 -- Having converted the arguments into the ame_atu_rec
463 -- plsql record structure we must call the corresponding entity
464 -- business process
465 --
466 ame_atu_del.del
467 (p_effective_date
468 ,p_datetrack_mode
469 ,l_rec
470 );
471 --
472 --
473 -- Set the out arguments
474 --
475 p_object_version_number := l_rec.object_version_number;
476 p_start_date := l_rec.start_date;
477 p_end_date := l_rec.end_date;
478 --
479 hr_utility.set_location(' Leaving:'||l_proc, 10);
480 End del;
481 --
482 end ame_atu_del;