1 Package Body pqh_rmr_del as
2 /* $Header: pqrmrrhi.pkb 120.0 2005/05/29 02:34 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_rmr_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 pqh_rmr_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 pqh_rate_matrix_rates_f
72 where rate_matrix_rate_id = p_rec.rate_matrix_rate_id
73 and effective_start_date = p_validation_start_date;
74 --
75 --
76 Else
77 --
78 --
79 -- Delete the row(s) where the effective start date is greater than
80 -- or equal to the validation start date.
81 --
82 delete from pqh_rate_matrix_rates_f
83 where rate_matrix_rate_id = p_rec.rate_matrix_rate_id
84 and effective_start_date >= p_validation_start_date;
85 --
86 --
87 End If;
88 --
89 hr_utility.set_location(' Leaving:'||l_proc, 20);
90 --
91 End dt_delete_dml;
92 --
93 -- ----------------------------------------------------------------------------
94 -- ----------------------< delete_app_ownerships >----------------------------|
95 -- ----------------------------------------------------------------------------
96 --
97 -- Description:
98 -- Deletes row(s) from hr_application_ownerships depending on the mode that
99 -- the row handler has been called in.
100 --
101 -- ----------------------------------------------------------------------------
102 PROCEDURE delete_app_ownerships(p_pk_column IN varchar2
103 ,p_pk_value IN varchar2
104 ,p_datetrack_mode IN varchar2) IS
105 --
106 BEGIN
107 --
108 IF ((hr_startup_data_api_support.return_startup_mode
109 IN ('STARTUP','GENERIC')) AND
110 p_datetrack_mode = 'ZAP') THEN
111 --
112 DELETE FROM hr_application_ownerships
113 WHERE key_name = p_pk_column
114 AND key_value = p_pk_value;
115 --
116 END IF;
117 END delete_app_ownerships;
118 --
119 -- ----------------------------------------------------------------------------
120 -- ----------------------< delete_app_ownerships >----------------------------|
121 -- ----------------------------------------------------------------------------
122 PROCEDURE delete_app_ownerships(p_pk_column IN varchar2
123 ,p_pk_value IN number
124 ,p_datetrack_mode IN varchar2) IS
125 --
126 BEGIN
127 delete_app_ownerships(p_pk_column,
128 to_char(p_pk_value),
129 p_datetrack_mode
130 );
131 END delete_app_ownerships;
132 --
133 -- ----------------------------------------------------------------------------
134 -- |------------------------------< delete_dml >------------------------------|
135 -- ----------------------------------------------------------------------------
136 Procedure delete_dml
137 (p_rec in out nocopy pqh_rmr_shd.g_rec_type
138 ,p_effective_date in date
139 ,p_datetrack_mode in varchar2
140 ,p_validation_start_date in date
141 ,p_validation_end_date in date
142 ) is
143 --
144 l_proc varchar2(72) := g_package||'delete_dml';
145 --
146 Begin
147 hr_utility.set_location('Entering:'||l_proc, 5);
148 --
149 pqh_rmr_del.dt_delete_dml
150 (p_rec => p_rec
151 ,p_effective_date => p_effective_date
152 ,p_datetrack_mode => p_datetrack_mode
153 ,p_validation_start_date => p_validation_start_date
154 ,p_validation_end_date => p_validation_end_date
155 );
156 --
157 hr_utility.set_location(' Leaving:'||l_proc, 10);
158 End delete_dml;
159 --
160 -- ----------------------------------------------------------------------------
161 -- |----------------------------< dt_pre_delete >-----------------------------|
162 -- ----------------------------------------------------------------------------
163 -- {Start Of Comments}
164 --
165 -- Description:
166 -- The dt_pre_delete process controls the execution of dml
167 -- for the datetrack modes: DELETE, FUTURE_CHANGE
168 -- and DELETE_NEXT_CHANGE only.
169 --
170 -- Prerequisites:
171 -- This is an internal procedure which is called from the pre_delete
172 -- procedure.
173 --
174 -- In Parameters:
175 -- A Pl/Sql record structure.
176 --
177 -- Post Success:
178 -- Processing continues.
179 --
180 -- Post Failure:
181 -- If an error has occurred, an error message and exception will be raised
182 -- but not handled.
183 --
184 -- Developer Implementation Notes:
185 -- This is an internal procedure which is required by Datetrack. Don't
186 -- remove or modify.
187 --
188 -- Access Status:
189 -- Internal Row Handler Use Only.
190 --
191 -- {End Of Comments}
192 -- ----------------------------------------------------------------------------
193 Procedure dt_pre_delete
194 (p_rec in out nocopy pqh_rmr_shd.g_rec_type
195 ,p_effective_date in date
196 ,p_datetrack_mode in varchar2
197 ,p_validation_start_date in date
198 ,p_validation_end_date in date
199 ) is
200 --
201 l_proc varchar2(72) := g_package||'dt_pre_delete';
202 --
203 Begin
204 hr_utility.set_location('Entering:'||l_proc, 5);
205 --
206 If (p_datetrack_mode <> hr_api.g_zap) then
207 --
208 p_rec.effective_start_date
209 := pqh_rmr_shd.g_old_rec.effective_start_date;
210 --
211 If (p_datetrack_mode = hr_api.g_delete) then
212 p_rec.effective_end_date := p_validation_start_date - 1;
213 Else
214 p_rec.effective_end_date := p_validation_end_date;
215 End If;
216 --
217 -- Update the current effective end date record
218 --
219 pqh_rmr_shd.upd_effective_end_date
220 (p_effective_date => p_effective_date
221 ,p_base_key_value => p_rec.rate_matrix_rate_id
222 ,p_new_effective_end_date => p_rec.effective_end_date
223 ,p_validation_start_date => p_validation_start_date
224 ,p_validation_end_date => p_validation_end_date
225 ,p_object_version_number => p_rec.object_version_number
226 );
227 Else
228 p_rec.effective_start_date := null;
229 p_rec.effective_end_date := null;
230 End If;
231 hr_utility.set_location(' Leaving:'||l_proc, 10);
232 End dt_pre_delete;
233 --
234 -- ----------------------------------------------------------------------------
235 -- |------------------------------< pre_delete >------------------------------|
236 -- ----------------------------------------------------------------------------
237 -- {Start Of Comments}
238 --
239 -- Description:
240 -- This private procedure contains any processing which is required before
241 -- the delete dml.
242 --
243 -- Prerequisites:
244 -- This is an internal procedure which is called from the del procedure.
245 --
246 -- In Parameters:
247 -- A Pl/Sql record structure.
248 --
249 -- Post Success:
250 -- Processing continues.
251 --
252 -- Post Failure:
253 -- If an error has occurred, an error message and exception will be raised
254 -- but not handled.
255 --
256 -- Developer Implementation Notes:
257 -- Any pre-processing required before the delete dml is issued should be
258 -- coded within this procedure. It is important to note that any 3rd party
259 -- maintenance should be reviewed before placing in this procedure. The call
260 -- to the dt_delete_dml procedure should NOT be removed.
261 --
262 -- Access Status:
263 -- Internal Row Handler Use Only.
264 --
265 -- {End Of Comments}
266 -- ----------------------------------------------------------------------------
267 Procedure pre_delete
268 (p_rec in out nocopy pqh_rmr_shd.g_rec_type
269 ,p_effective_date in date
270 ,p_datetrack_mode in varchar2
271 ,p_validation_start_date in date
272 ,p_validation_end_date in date
273 ) is
274 --
275 l_proc varchar2(72) := g_package||'pre_delete';
276 --
277 --
278 --
279 Begin
280 hr_utility.set_location('Entering:'||l_proc, 5);
281 --
282 --
283 --
284 pqh_rmr_del.dt_pre_delete
285 (p_rec => p_rec
286 ,p_effective_date => p_effective_date
287 ,p_datetrack_mode => p_datetrack_mode
288 ,p_validation_start_date => p_validation_start_date
289 ,p_validation_end_date => p_validation_end_date
290 );
291 --
292 hr_utility.set_location(' Leaving:'||l_proc, 10);
293 End pre_delete;
294 --
295 -- ----------------------------------------------------------------------------
296 -- |----------------------------< post_delete >-------------------------------|
297 -- ----------------------------------------------------------------------------
298 -- {Start Of Comments}
299 --
300 -- Description:
301 -- This private procedure contains any processing which is required after
302 -- the delete dml.
303 --
304 -- Prerequisites:
305 -- This is an internal procedure which is called from the del procedure.
306 --
307 -- In Parameters:
308 -- A Pl/Sql record structure.
309 --
310 -- Post Success:
311 -- Processing continues.
312 --
313 -- Post Failure:
314 -- If an error has occurred, an error message and exception will be raised
315 -- but not handled.
316 --
317 -- Developer Implementation Notes:
318 -- Any post-processing required after the delete dml is issued should be
319 -- coded within this procedure. It is important to note that any 3rd party
320 -- maintenance should be reviewed before placing in this procedure.
321 --
322 -- Access Status:
323 -- Internal Row Handler Use Only.
324 --
325 -- {End Of Comments}
326 -- ----------------------------------------------------------------------------
327 Procedure post_delete
328 (p_rec in pqh_rmr_shd.g_rec_type
329 ,p_effective_date in date
330 ,p_datetrack_mode in varchar2
331 ,p_validation_start_date in date
332 ,p_validation_end_date in date
333 ) is
334 --
335 l_proc varchar2(72) := g_package||'post_delete';
336 --
337 Begin
338 hr_utility.set_location('Entering:'||l_proc, 5);
339 begin
340 --
341 -- Delete ownerships if applicable
342 delete_app_ownerships
343 ('RATE_MATRIX_RATE_ID', p_rec.rate_matrix_rate_id
344 ,p_datetrack_mode
345 );
346 --
347 pqh_rmr_rkd.after_delete
348 (p_effective_date
349 => p_effective_date
350 ,p_datetrack_mode
351 => p_datetrack_mode
352 ,p_validation_start_date
353 => p_validation_start_date
354 ,p_validation_end_date
355 => p_validation_end_date
356 ,p_rate_matrix_rate_id
357 => p_rec.rate_matrix_rate_id
358 ,p_effective_start_date
359 => p_rec.effective_start_date
360 ,p_effective_end_date
361 => p_rec.effective_end_date
362 ,p_effective_start_date_o
363 => pqh_rmr_shd.g_old_rec.effective_start_date
364 ,p_effective_end_date_o
365 => pqh_rmr_shd.g_old_rec.effective_end_date
366 ,p_rate_matrix_node_id_o
367 => pqh_rmr_shd.g_old_rec.rate_matrix_node_id
368 ,p_criteria_rate_defn_id_o
369 => pqh_rmr_shd.g_old_rec.criteria_rate_defn_id
370 ,p_min_rate_value_o
371 => pqh_rmr_shd.g_old_rec.min_rate_value
372 ,p_max_rate_value_o
373 => pqh_rmr_shd.g_old_rec.max_rate_value
374 ,p_mid_rate_value_o
375 => pqh_rmr_shd.g_old_rec.mid_rate_value
376 ,p_rate_value_o
377 => pqh_rmr_shd.g_old_rec.rate_value
378 ,p_business_group_id_o
379 => pqh_rmr_shd.g_old_rec.business_group_id
380 ,p_legislation_code_o
381 => pqh_rmr_shd.g_old_rec.legislation_code
382 ,p_object_version_number_o
383 => pqh_rmr_shd.g_old_rec.object_version_number
384 );
385 --
386 exception
387 --
388 when hr_api.cannot_find_prog_unit then
389 --
390 hr_api.cannot_find_prog_unit_error
391 (p_module_name => 'PQH_RATE_MATRIX_RATES_F'
392 ,p_hook_type => 'AD');
393 --
394 end;
395 --
396 hr_utility.set_location(' Leaving:'||l_proc, 10);
397 End post_delete;
398 --
399 -- ----------------------------------------------------------------------------
400 -- |---------------------------------< del >----------------------------------|
401 -- ----------------------------------------------------------------------------
402 Procedure del
403 (p_effective_date in date
404 ,p_datetrack_mode in varchar2
405 ,p_rec in out nocopy pqh_rmr_shd.g_rec_type
406 ) is
407 --
408 l_proc varchar2(72) := g_package||'del';
409 l_validation_start_date date;
410 l_validation_end_date date;
411 --
412 Begin
413 hr_utility.set_location('Entering:'||l_proc, 5);
414 --
415 -- Ensure that the DateTrack delete mode is valid
416 --
417 dt_api.validate_dt_del_mode(p_datetrack_mode => p_datetrack_mode);
418 --
419 -- We must lock the row which we need to delete.
420 --
421 pqh_rmr_shd.lck
422 (p_effective_date => p_effective_date
423 ,p_datetrack_mode => p_datetrack_mode
424 ,p_rate_matrix_rate_id => p_rec.rate_matrix_rate_id
425 ,p_object_version_number => p_rec.object_version_number
426 ,p_validation_start_date => l_validation_start_date
427 ,p_validation_end_date => l_validation_end_date
428 );
429 --
430 -- Call the supporting delete validate operation
431 --
432 pqh_rmr_bus.delete_validate
433 (p_rec => p_rec
434 ,p_effective_date => p_effective_date
435 ,p_datetrack_mode => p_datetrack_mode
436 ,p_validation_start_date => l_validation_start_date
437 ,p_validation_end_date => l_validation_end_date
438 );
439 --
440 -- Call to raise any errors on multi-message list
441 hr_multi_message.end_validation_set;
442 --
443 -- Call the supporting pre-delete operation
444 --
445 pqh_rmr_del.pre_delete
446 (p_rec => p_rec
447 ,p_effective_date => p_effective_date
448 ,p_datetrack_mode => p_datetrack_mode
449 ,p_validation_start_date => l_validation_start_date
450 ,p_validation_end_date => l_validation_end_date
451 );
452 --
453 -- Delete the row.
454 --
455 pqh_rmr_del.delete_dml
456 (p_rec => p_rec
457 ,p_effective_date => p_effective_date
458 ,p_datetrack_mode => p_datetrack_mode
459 ,p_validation_start_date => l_validation_start_date
460 ,p_validation_end_date => l_validation_end_date
461 );
462 -- Call the supporting post-delete operation
463 --
464 pqh_rmr_del.post_delete
465 (p_rec => p_rec
466 ,p_effective_date => p_effective_date
467 ,p_datetrack_mode => p_datetrack_mode
468 ,p_validation_start_date => l_validation_start_date
469 ,p_validation_end_date => l_validation_end_date
470 );
471 --
472 -- Call to raise any errors on multi-message list
473 hr_multi_message.end_validation_set;
474 --
475 hr_utility.set_location(' Leaving:'||l_proc, 5);
476 End del;
477 --
478 -- ----------------------------------------------------------------------------
479 -- |--------------------------------< del >-----------------------------------|
480 -- ----------------------------------------------------------------------------
481 Procedure del
482 (p_effective_date in date
483 ,p_datetrack_mode in varchar2
484 ,p_rate_matrix_rate_id in number
485 ,p_object_version_number in out nocopy number
486 ,p_effective_start_date out nocopy date
487 ,p_effective_end_date out nocopy date
488 ) is
489 --
490 l_rec pqh_rmr_shd.g_rec_type;
491 l_proc varchar2(72) := g_package||'del';
492 --
493 Begin
494 hr_utility.set_location('Entering:'||l_proc, 5);
495 --
496 -- As the delete procedure accepts a plsql record structure we do need to
497 -- convert the arguments into the record structure.
498 -- We don't need to call the supplied conversion argument routine as we
499 -- only need a few attributes.
500 --
501 l_rec.rate_matrix_rate_id := p_rate_matrix_rate_id;
502 l_rec.object_version_number := p_object_version_number;
503 --
504 -- Having converted the arguments into the pqh_rmr_rec
505 -- plsql record structure we must call the corresponding entity
506 -- business process
507 --
508 pqh_rmr_del.del
509 (p_effective_date
510 ,p_datetrack_mode
511 ,l_rec
512 );
513 --
514 --
515 -- Set the out arguments
516 --
517 p_object_version_number := l_rec.object_version_number;
518 p_effective_start_date := l_rec.effective_start_date;
519 p_effective_end_date := l_rec.effective_end_date;
520 --
521 hr_utility.set_location(' Leaving:'||l_proc, 10);
522 End del;
523 --
524 end pqh_rmr_del;