1 Package Body irc_iad_upd as
2 /* $Header: iriadrhi.pkb 120.3.12000000.2 2007/03/23 07:14:06 vboggava noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' irc_iad_upd.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |----------------------------< dt_update_dml >-----------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 -- This procedure controls the execution of dml from the datetrack mode
17 -- of CORRECTION only. It is important to note that the object version
18 -- number is only increment by 1 because the datetrack correction is
19 -- soley for one datetracked row.
20 -- This procedure controls the actual dml update logic. The functions of
21 -- this procedure are as follows:
22 -- 1) Get the next object_version_number.
23 -- 2) To set and unset the g_api_dml status as required (as we are about to
24 -- perform dml).
25 -- 3) To update the specified row in the schema using the primary key in
26 -- the predicates.
27 -- 4) To trap any constraint violations that may have occurred.
28 -- 5) To raise any other errors.
29 --
30 -- Prerequisites:
31 -- This is an internal private procedure which must be called from the
32 -- update_dml procedure.
33 --
34 -- In Parameters:
35 -- A Pl/Sql record structure.
36 --
37 -- Post Success:
38 -- The specified row will be updated in the schema.
39 --
40 -- Post Failure:
41 -- On the update dml failure it is important to note that we always reset the
42 -- g_api_dml status to false.
43 -- If a check or unique integrity constraint violation is raised the
44 -- constraint_error procedure will be called.
45 -- If any other error is reported, the error will be raised after the
46 -- g_api_dml status is reset.
47 --
48 -- Developer Implementation Notes:
49 -- The update 'set' arguments list should be modified if any of your
50 -- attributes are not updateable.
51 --
52 -- Access Status:
53 -- Internal Row Handler Use Only.
54 --
55 -- {End Of Comments}
56 -- ----------------------------------------------------------------------------
57 Procedure dt_update_dml
58 (p_rec in out nocopy irc_iad_shd.g_rec_type
59 ,p_effective_date in date
60 ,p_datetrack_mode in varchar2
61 ,p_validation_start_date in date
62 ,p_validation_end_date in date
63 ) is
64 --
65 l_proc varchar2(72) := g_package||'dt_update_dml';
66 --
67 Begin
68 hr_utility.set_location('Entering:'||l_proc, 5);
69 --
70 If (p_datetrack_mode = hr_api.g_correction) then
71 hr_utility.set_location(l_proc, 10);
72 --
73 -- Because we are updating a row we must get the next object
74 -- version number.
75 --
76 p_rec.object_version_number :=
77 dt_api.get_object_version_number
78 (p_base_table_name => 'irc_assignment_details_f'
79 ,p_base_key_column => 'assignment_details_id'
80 ,p_base_key_value => p_rec.assignment_details_id
81 );
82 --
83 --
84 --
85 -- Update the irc_assignment_details_f Row
86 --
87 update irc_assignment_details_f
88 set
89 assignment_details_id = p_rec.assignment_details_id
90 ,assignment_id = p_rec.assignment_id
91 ,details_version = p_rec.details_version
92 ,latest_details = p_rec.latest_details
93 ,attempt_id = p_rec.attempt_id
94 ,qualified = p_rec.qualified
95 ,considered = p_rec.considered
96 ,object_version_number = p_rec.object_version_number
97 where assignment_details_id = p_rec.assignment_details_id
98 and effective_start_date = p_validation_start_date
99 and effective_end_date = p_validation_end_date;
100 --
101 --
102 --
103 -- Set the effective start and end dates
104 --
105 p_rec.effective_start_date := p_validation_start_date;
106 p_rec.effective_end_date := p_validation_end_date;
107 End If;
108 --
109 hr_utility.set_location(' Leaving:'||l_proc, 15);
110 Exception
111 When hr_api.check_integrity_violated Then
112 -- A check constraint has been violated
113 --
114 irc_iad_shd.constraint_error
115 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
116 When hr_api.unique_integrity_violated Then
117 -- Unique integrity has been violated
118 --
119 irc_iad_shd.constraint_error
120 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
121 When Others Then
122 --
123 Raise;
124 End dt_update_dml;
125 --
126 -- ----------------------------------------------------------------------------
127 -- |------------------------------< update_dml >------------------------------|
128 -- ----------------------------------------------------------------------------
129 -- {Start Of Comments}
130 --
131 -- Description:
132 -- This procedure calls the dt_update_dml control logic which handles
133 -- the actual datetrack dml.
134 --
135 -- Prerequisites:
136 -- This is an internal private procedure which must be called from the upd
137 -- procedure.
138 --
139 -- In Parameters:
140 -- A Pl/Sql record structre.
141 --
142 -- Post Success:
143 -- Processing contines.
144 --
145 -- Post Failure:
146 -- No specific error handling is required within this procedure.
147 --
148 -- Developer Implementation Notes:
149 -- The update 'set' arguments list should be modified if any of your
150 -- attributes are not updateable.
151 --
152 -- Access Status:
153 -- Internal Row Handler Use Only.
154 --
155 -- {End Of Comments}
156 -- ----------------------------------------------------------------------------
157 Procedure update_dml
158 (p_rec in out nocopy irc_iad_shd.g_rec_type
159 ,p_effective_date in date
160 ,p_datetrack_mode in varchar2
161 ,p_validation_start_date in date
162 ,p_validation_end_date in date
163 ) is
164 --
165 l_proc varchar2(72) := g_package||'update_dml';
166 --
167 Begin
168 hr_utility.set_location('Entering:'||l_proc, 5);
169 --
170 irc_iad_upd.dt_update_dml
171 (p_rec => p_rec
172 ,p_effective_date => p_effective_date
173 ,p_datetrack_mode => p_datetrack_mode
174 ,p_validation_start_date => p_validation_start_date
175 ,p_validation_end_date => p_validation_end_date
176 );
177 --
178 hr_utility.set_location(' Leaving:'||l_proc, 10);
179 End update_dml;
180 --
181 -- ----------------------------------------------------------------------------
182 -- |----------------------------< dt_pre_update >-----------------------------|
183 -- ----------------------------------------------------------------------------
184 -- {Start Of Comments}
185 --
186 -- Description:
187 -- The dt_pre_update procedure controls the execution
188 -- of dml for the datetrack modes of: UPDATE, UPDATE_OVERRIDE
189 -- and UPDATE_CHANGE_INSERT only. The execution required is as
190 -- follows:
191 --
192 -- 1) Providing the datetrack update mode is not 'CORRECTION'
193 -- then set the effective end date of the current row (this
194 -- will be the validation_start_date - 1).
195 -- 2) If the datetrack mode is 'UPDATE_OVERRIDE' then call the
196 -- corresponding delete_dml process to delete any future rows
197 -- where the effective_start_date is greater than or equal to
198 -- the validation_start_date.
199 -- 3) Call the insert_dml process to insert the new updated row
200 -- details.
201 --
202 -- Prerequisites:
203 -- This is an internal procedure which is called from the
204 -- pre_update procedure.
205 --
206 -- In Parameters:
207 --
208 -- Post Success:
209 -- Processing continues.
210 --
211 -- Post Failure:
212 -- If an error has occurred, an error message and exception will be raised
213 -- but not handled.
214 --
215 -- Developer Implementation Notes:
216 -- This is an internal procedure which is required by Datetrack. Don't
217 -- remove or modify.
218 --
219 -- Access Status:
220 -- Internal Row Handler Use Only.
221 --
222 -- {End Of Comments}
223 -- ----------------------------------------------------------------------------
224 Procedure dt_pre_update
225 (p_rec in out nocopy irc_iad_shd.g_rec_type
226 ,p_effective_date in date
227 ,p_datetrack_mode in varchar2
228 ,p_validation_start_date in date
229 ,p_validation_end_date in date
230 ) is
231 --
232 l_proc varchar2(72) := g_package||'dt_pre_update';
233 l_dummy_version_number number;
234 --
235 Begin
236 hr_utility.set_location('Entering:'||l_proc, 5);
237 If (p_datetrack_mode <> hr_api.g_correction) then
238 --
239 -- Update the current effective end date
240 --
241 hr_utility.set_location(l_proc, 10);
242 irc_iad_shd.upd_effective_end_date
243 (p_effective_date => p_effective_date
244 ,p_base_key_value => p_rec.assignment_id
245 ,p_new_effective_end_date => (p_validation_start_date - 1)
246 ,p_validation_start_date => p_validation_start_date
247 ,p_validation_end_date => p_validation_end_date
248 ,p_object_version_number => l_dummy_version_number
249 );
250 --
251 If (p_datetrack_mode = hr_api.g_update_override) then
252 --
253 -- As the datetrack mode is 'UPDATE_OVERRIDE' then we must
254 -- delete any future rows
255 --
256 hr_utility.set_location(l_proc, 20);
257 irc_iad_del.delete_dml
258 (p_rec => p_rec
259 ,p_effective_date => p_effective_date
260 ,p_datetrack_mode => p_datetrack_mode
261 ,p_validation_start_date => p_validation_start_date
262 ,p_validation_end_date => p_validation_end_date
263 );
264 End If;
265 Else
266 -- Correction mode
267 --
268 -- Reset the Latest Details flag for the current effective date range rows.
269 hr_utility.set_location(l_proc, 30);
270 p_rec.object_version_number :=
271 dt_api.get_object_version_number
272 (p_base_table_name => 'irc_assignment_details_f'
273 ,p_base_key_column => 'assignment_id'
274 ,p_base_key_value => p_rec.assignment_id
275 );
276 update irc_assignment_details_f
277 set latest_details = 'N'
278 ,object_version_number = p_rec.object_version_number
279 where assignment_id = p_rec.assignment_id
280 and latest_details = 'Y'
281 and p_effective_date
282 between effective_start_date and effective_end_date;
283 End If;
284 --
285 -- We need to insert a new row, so get a new surrogate key if necessary.
286 --
287 hr_utility.set_location(l_proc, 40);
288 irc_iad_ins.pre_insert
289 (p_rec => p_rec
290 ,p_effective_date => p_effective_date
291 ,p_datetrack_mode => p_datetrack_mode
292 ,p_validation_start_date => p_validation_start_date
293 ,p_validation_end_date => p_validation_end_date
294 );
295 --
296 -- We must now insert the updated row
297 --
298 irc_iad_ins.insert_dml
299 (p_rec => p_rec
300 ,p_effective_date => p_effective_date
301 ,p_datetrack_mode => p_datetrack_mode
302 ,p_validation_start_date => p_validation_start_date
303 ,p_validation_end_date => p_validation_end_date
304 );
305 hr_utility.set_location(' Leaving:'||l_proc, 50);
306 End dt_pre_update;
307 --
308 -- ----------------------------------------------------------------------------
309 -- |------------------------------< pre_update >------------------------------|
310 -- ----------------------------------------------------------------------------
311 -- {Start Of Comments}
312 --
313 -- Description:
314 -- This private procedure contains any processing which is required before
315 -- the update dml.
316 --
317 -- Prerequisites:
318 -- This is an internal procedure which is called from the upd procedure.
319 --
320 -- In Parameters:
321 -- A Pl/Sql record structure.
322 --
323 -- Post Success:
324 -- Processing continues.
325 --
326 -- Post Failure:
327 -- If an error has occurred, an error message and exception will be raised
328 -- but not handled.
329 -- Developer Implementation Notes:
330 -- Any pre-processing required before the update dml is issued should be
331 -- coded within this procedure. It is important to note that any 3rd party
332 -- maintenance should be reviewed before placing in this procedure. The call
333 -- to the dt_update_dml procedure should NOT be removed.
334 --
335 -- Access Status:
336 -- Internal Row Handler Use Only.
337 --
338 -- {End Of Comments}
339 -- ----------------------------------------------------------------------------
340 Procedure pre_update
341 (p_rec in out nocopy irc_iad_shd.g_rec_type
342 ,p_effective_date in date
343 ,p_datetrack_mode in varchar2
344 ,p_validation_start_date in date
345 ,p_validation_end_date in date
346 ) is
347 --
348 l_proc varchar2(72) := g_package||'pre_update';
349 --
350 Begin
351 hr_utility.set_location('Entering:'||l_proc, 5);
352 --
353 --
354 --
355 dt_pre_update
356 (p_rec => p_rec
357 ,p_effective_date => p_effective_date
358 ,p_datetrack_mode => p_datetrack_mode
359 ,p_validation_start_date => p_validation_start_date
360 ,p_validation_end_date => p_validation_end_date
361 );
362 --
363 hr_utility.set_location(' Leaving:'||l_proc, 10);
364 End pre_update;
365 --
366 -- ----------------------------------------------------------------------------
367 -- |----------------------------< post_update >-------------------------------|
368 -- ----------------------------------------------------------------------------
369 -- {Start Of Comments}
370 --
371 -- Description:
372 -- This private procedure contains any processing which is required after
373 -- the update dml.
374 --
375 -- Prerequisites:
376 -- This is an internal procedure which is called from the upd procedure.
377 --
378 -- In Parameters:
379 -- A Pl/Sql record structure.
380 --
381 -- Post Success:
382 -- Processing continues.
383 --
384 -- Post Failure:
385 -- If an error has occurred, an error message and exception will be raised
386 -- but not handled.
387 --
388 -- Developer Implementation Notes:
389 -- Any post-processing required after the update dml is issued should be
390 -- coded within this procedure. It is important to note that any 3rd party
391 -- maintenance should be reviewed before placing in this procedure.
392 --
393 -- Access Status:
394 -- Internal Row Handler Use Only.
395 --
396 -- {End Of Comments}
397 -- ----------------------------------------------------------------------------
398 Procedure post_update
399 (p_rec in irc_iad_shd.g_rec_type
400 ,p_effective_date in date
401 ,p_datetrack_mode in varchar2
402 ,p_validation_start_date in date
403 ,p_validation_end_date in date
404 ) is
405 --
406 l_proc varchar2(72) := g_package||'post_update';
407 --
408 Begin
409 hr_utility.set_location('Entering:'||l_proc, 5);
410 begin
411 --
412 irc_iad_rku.after_update
413 (p_effective_date
414 => p_effective_date
415 ,p_datetrack_mode
416 => p_datetrack_mode
417 ,p_validation_start_date
418 => p_validation_start_date
419 ,p_validation_end_date
420 => p_validation_end_date
421 ,p_assignment_details_id
422 => p_rec.assignment_details_id
423 ,p_assignment_id
424 => p_rec.assignment_id
425 ,p_qualified
426 => p_rec.qualified
427 ,p_considered
428 => p_rec.considered
429 ,p_effective_start_date
430 => p_rec.effective_start_date
431 ,p_effective_end_date
432 => p_rec.effective_end_date
433 ,p_details_version
434 => p_rec.details_version
435 ,p_latest_details
436 => p_rec.latest_details
437 ,p_attempt_id
438 => p_rec.attempt_id
439 ,p_object_version_number
440 => p_rec.object_version_number
441 ,p_assignment_id_o
442 => irc_iad_shd.g_old_rec.assignment_id
443 ,p_effective_start_date_o
444 => irc_iad_shd.g_old_rec.effective_start_date
445 ,p_effective_end_date_o
446 => irc_iad_shd.g_old_rec.effective_end_date
447 ,p_details_version_o
448 => irc_iad_shd.g_old_rec.details_version
449 ,p_latest_details_o
450 => irc_iad_shd.g_old_rec.latest_details
451 ,p_attempt_id_o
452 => irc_iad_shd.g_old_rec.attempt_id
453 ,p_qualified_o
454 => irc_iad_shd.g_old_rec.qualified
455 ,p_considered_o
456 => irc_iad_shd.g_old_rec.considered
457 ,p_object_version_number_o
458 => irc_iad_shd.g_old_rec.object_version_number
459 );
460 --
461 exception
462 --
463 when hr_api.cannot_find_prog_unit then
464 --
465 hr_api.cannot_find_prog_unit_error
466 (p_module_name => 'IRC_ASSIGNMENT_DETAILS_F'
467 ,p_hook_type => 'AU');
468 --
469 end;
470 --
471 hr_utility.set_location(' Leaving:'||l_proc, 10);
472 End post_update;
473 --
474 -- ----------------------------------------------------------------------------
475 -- |-----------------------------< convert_defs >-----------------------------|
476 -- ----------------------------------------------------------------------------
477 -- {Start Of Comments}
478 --
479 -- Description:
480 -- The Convert_Defs procedure has one very important function:
481 -- It must return the record structure for the row with all system defaulted
482 -- values converted into its corresponding parameter value for update. When
483 -- we attempt to update a row through the Upd process , certain
484 -- parameters can be defaulted which enables flexibility in the calling of
485 -- the upd process (e.g. only attributes which need to be updated need to be
486 -- specified). For the upd process to determine which attributes
487 -- have NOT been specified we need to check if the parameter has a reserved
488 -- system default value. Therefore, for all parameters which have a
489 -- corresponding reserved system default mechanism specified we need to
490 -- check if a system default is being used. If a system default is being
491 -- used then we convert the defaulted value into its corresponding attribute
492 -- value held in the g_old_rec data structure.
493 --
494 -- Prerequisites:
495 -- This private function can only be called from the upd process.
496 --
497 -- In Parameters:
498 -- A Pl/Sql record structure.
499 --
500 -- Post Success:
501 -- The record structure will be returned with all system defaulted parameter
502 -- values converted into its current row attribute value.
503 --
504 -- Post Failure:
505 -- No direct error handling is required within this function. Any possible
506 -- errors within this procedure will be a PL/SQL value error due to
507 -- conversion of datatypes or data lengths.
508 --
509 -- Developer Implementation Notes:
510 -- None.
511 --
512 -- Access Status:
513 -- Internal Row Handler Use Only.
514 --
515 -- {End Of Comments}
516 -- ----------------------------------------------------------------------------
517 Procedure convert_defs
518 (p_rec in out nocopy irc_iad_shd.g_rec_type
519 ) is
520 --
521 Begin
522 --
523 -- We must now examine each argument value in the
524 -- p_rec plsql record structure
525 -- to see if a system default is being used. If a system default
526 -- is being used then we must set to the 'current' argument value.
527 --
528 If (p_rec.assignment_id = hr_api.g_number) then
529 p_rec.assignment_id :=
530 irc_iad_shd.g_old_rec.assignment_id;
531 End If;
532 If (p_rec.effective_start_date = hr_api.g_date) then
533 p_rec.effective_start_date :=
534 irc_iad_shd.g_old_rec.effective_start_date;
535 End If;
536 If (p_rec.effective_end_date = hr_api.g_date) then
537 p_rec.effective_end_date :=
538 irc_iad_shd.g_old_rec.effective_end_date;
539 End If;
540 If (p_rec.details_version = hr_api.g_number) then
541 p_rec.details_version :=
542 irc_iad_shd.g_old_rec.details_version;
543 End If;
544 If (p_rec.latest_details = hr_api.g_varchar2) then
545 p_rec.latest_details :=
546 irc_iad_shd.g_old_rec.latest_details;
547 End If;
548 If (p_rec.attempt_id = hr_api.g_number) then
549 p_rec.attempt_id :=
550 irc_iad_shd.g_old_rec.attempt_id;
551 End If;
552 --
553 End convert_defs;
554 --
555 -- ----------------------------------------------------------------------------
556 -- |---------------------------------< upd >----------------------------------|
557 -- ----------------------------------------------------------------------------
558 Procedure upd
559 (p_effective_date in date
560 ,p_datetrack_mode in varchar2
561 ,p_rec in out nocopy irc_iad_shd.g_rec_type
562 ) is
563 --
564 l_proc varchar2(72) := g_package||'upd';
565 l_validation_start_date date;
566 l_validation_end_date date;
567 --
568 Begin
569 hr_utility.set_location('Entering:'||l_proc, 5);
570 --
571 -- Ensure that the DateTrack update mode is valid
572 --
573 dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode);
574 --
575 -- We must lock the row which we need to update.
576 --
577 irc_iad_shd.lck
578 (p_effective_date => p_effective_date
579 ,p_datetrack_mode => p_datetrack_mode
580 ,p_assignment_details_id => p_rec.assignment_details_id
581 ,p_object_version_number => p_rec.object_version_number
582 ,p_validation_start_date => l_validation_start_date
583 ,p_validation_end_date => l_validation_end_date
584 );
585 --
586 -- 1. During an update system defaults are used to determine if
587 -- arguments have been defaulted or not. We must therefore
588 -- derive the full record structure values to be updated.
589 --
590 -- 2. Call the supporting update validate operations.
591 --
592 irc_iad_upd.convert_defs(p_rec);
593 --
594 irc_iad_bus.update_validate
595 (p_rec => p_rec
596 ,p_effective_date => p_effective_date
597 ,p_datetrack_mode => p_datetrack_mode
598 ,p_validation_start_date => l_validation_start_date
599 ,p_validation_end_date => l_validation_end_date
600 );
601 --
602 -- Call to raise any errors on multi-message list
603 hr_multi_message.end_validation_set;
604 --
605 -- Call the supporting pre-update operation
606 --
607 pre_update
608 (p_rec => p_rec
609 ,p_effective_date => p_effective_date
610 ,p_datetrack_mode => p_datetrack_mode
611 ,p_validation_start_date => l_validation_start_date
612 ,p_validation_end_date => l_validation_end_date
613 );
614 --
615 -- No need to call update_dml as we never overwrite the existing
616 -- row data but instead create a new version even for correction mode
617 --
618 -- Call the supporting post-update operation
619 --
620 post_update
621 (p_rec => p_rec
622 ,p_effective_date => p_effective_date
623 ,p_datetrack_mode => p_datetrack_mode
624 ,p_validation_start_date => l_validation_start_date
625 ,p_validation_end_date => l_validation_end_date
626 );
627 --
628 -- Call to raise any errors on multi-message list
629 hr_multi_message.end_validation_set;
630 End upd;
631 --
632 -- ----------------------------------------------------------------------------
633 -- |------------------------------< upd >-------------------------------------|
634 -- ----------------------------------------------------------------------------
635 Procedure upd
636 (p_effective_date in date
637 ,p_datetrack_mode in varchar2
638 ,p_assignment_id in number default hr_api.g_number
639 ,p_attempt_id in number default hr_api.g_number
640 ,p_qualified in varchar2
641 ,p_considered in varchar2
642 ,p_assignment_details_id in out nocopy number
643 ,p_object_version_number in out nocopy number
644 ,p_effective_start_date out nocopy date
645 ,p_effective_end_date out nocopy date
646 ,p_details_version out nocopy number
647 ,p_latest_details out nocopy varchar2
648 ) is
649 --
650 l_rec irc_iad_shd.g_rec_type;
651 l_proc varchar2(72) := g_package||'upd';
652 --
653 Begin
654 hr_utility.set_location('Entering:'||l_proc, 5);
655 --
656 -- Call conversion function to turn arguments into the
657 -- l_rec structure.
658 --
659 l_rec :=
660 irc_iad_shd.convert_args
661 (p_assignment_details_id
662 ,p_assignment_id
663 ,null
664 ,null
665 ,null
666 ,null
667 ,p_attempt_id
668 ,p_qualified
669 ,p_considered
670 ,p_object_version_number
671 );
672 --
673 -- Having converted the arguments into the
674 -- plsql record structure we call the corresponding record
675 -- business process.
676 --
677 irc_iad_upd.upd
678 (p_effective_date
679 ,p_datetrack_mode
680 ,l_rec
681 );
682 --
683 -- Set the out parameters
684 --
685 p_assignment_details_id := l_rec.assignment_details_id;
686 p_details_version := l_rec.details_version;
687 p_latest_details := l_rec.latest_details;
688 p_object_version_number := l_rec.object_version_number;
689 p_effective_start_date := l_rec.effective_start_date;
690 p_effective_end_date := l_rec.effective_end_date;
691 --
692 --
693 hr_utility.set_location(' Leaving:'||l_proc, 10);
694 End upd;
695 --
696 end irc_iad_upd;