1 Package Body pay_grr_upd as
2 /* $Header: pygrrrhi.pkb 115.4 2002/12/10 09:48:17 pkakar ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_grr_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 this
21 -- 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 -- Pre Conditions:
31 -- This is an internal private procedure which must be called from the
32 -- update_dml procedure.
33 --
34 -- In Arguments:
35 -- A Pl/Sql record structre.
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 Table Handler USe Only.
54 --
55 -- {End Of Comments}
56 -- ----------------------------------------------------------------------------
57 Procedure dt_update_dml
58 (p_rec in out nocopy pay_grr_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) is
63 --
64 l_proc varchar2(72) := g_package||'dt_update_dml';
65 --
66 Begin
67 hr_utility.set_location('Entering:'||l_proc, 5);
68 --
69 If (p_datetrack_mode = 'CORRECTION') then
70 hr_utility.set_location(l_proc, 10);
71 --
72 -- Because we are updating a row we must get the next object
73 -- version number.
74 --
75 p_rec.object_version_number :=
76 dt_api.get_object_version_number
77 (p_base_table_name => 'pay_grade_rules_f',
78 p_base_key_column => 'grade_rule_id',
79 p_base_key_value => p_rec.grade_rule_id);
80 --
81 pay_grr_shd.g_api_dml := true; -- Set the api dml status
82 --
83 hr_utility.set_location(l_proc, 12);
84 --
85 -- Update the pay_grade_rules_f Row
86 --
87 update pay_grade_rules_f
88 set
89 grade_rule_id = p_rec.grade_rule_id,
90 maximum = p_rec.maximum,
91 mid_value = p_rec.mid_value,
92 minimum = p_rec.minimum,
93 value = p_rec.value,
94 request_id = p_rec.request_id,
95 program_application_id = p_rec.program_application_id,
96 program_id = p_rec.program_id,
97 program_update_date = p_rec.program_update_date,
98 object_version_number = p_rec.object_version_number,
99 currency_code = p_rec.currency_code
100 where grade_rule_id = p_rec.grade_rule_id
101 and effective_start_date = p_validation_start_date
102 and effective_end_date = p_validation_end_date;
103 --
104 hr_utility.set_location(l_proc, 14);
105 --
106 pay_grr_shd.g_api_dml := false; -- Unset the api dml status
107 --
108 -- Set the effective start and end dates
109 --
110 p_rec.effective_start_date := p_validation_start_date;
111 p_rec.effective_end_date := p_validation_end_date;
112 End If;
113 --
114 hr_utility.set_location(' Leaving:'||l_proc, 15);
115 Exception
116 When hr_api.check_integrity_violated Then
117 -- A check constraint has been violated
118 pay_grr_shd.g_api_dml := false; -- Unset the api dml status
119 pay_grr_shd.constraint_error
120 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
121 When hr_api.unique_integrity_violated Then
122 -- Unique integrity has been violated
123 pay_grr_shd.g_api_dml := false; -- Unset the api dml status
124 pay_grr_shd.constraint_error
125 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
126 When Others Then
127 pay_grr_shd.g_api_dml := false; -- Unset the api dml status
128 Raise;
129 End dt_update_dml;
130 --
131 -- ----------------------------------------------------------------------------
132 -- |------------------------------< update_dml >------------------------------|
133 -- ----------------------------------------------------------------------------
134 -- {Start Of Comments}
135 --
136 -- Description:
137 -- This procedure calls the dt_update_dml control logic which handles
138 -- the actual datetrack dml.
139 --
140 -- Pre Conditions:
141 -- This is an internal private procedure which must be called from the upd
142 -- procedure.
143 --
144 -- In Arguments:
145 -- A Pl/Sql record structre.
146 --
147 -- Post Success:
148 -- Processing contines.
149 --
150 -- Post Failure:
151 -- No specific error handling is required within this procedure.
152 --
153 -- Developer Implementation Notes:
154 -- The update 'set' arguments list should be modified if any of your
155 -- attributes are not updateable.
156 --
157 -- Access Status:
158 -- Internal Table Handler USe Only.
159 --
160 -- {End Of Comments}
161 -- ----------------------------------------------------------------------------
162 Procedure update_dml
163 (p_rec in out nocopy pay_grr_shd.g_rec_type,
164 p_effective_date in date,
165 p_datetrack_mode in varchar2,
166 p_validation_start_date in date,
167 p_validation_end_date in date) is
168 --
169 l_proc varchar2(72) := g_package||'update_dml';
170 --
171 Begin
172 hr_utility.set_location('Entering:'||l_proc, 5);
173 --
174 dt_update_dml(p_rec => p_rec,
175 p_effective_date => p_effective_date,
176 p_datetrack_mode => p_datetrack_mode,
177 p_validation_start_date => p_validation_start_date,
178 p_validation_end_date => p_validation_end_date);
179 --
180 hr_utility.set_location(' Leaving:'||l_proc, 10);
181 End update_dml;
182 --
183 -- ----------------------------------------------------------------------------
184 -- |----------------------------< dt_pre_update >-----------------------------|
185 -- ----------------------------------------------------------------------------
186 -- {Start Of Comments}
187 --
188 -- Description:
189 -- The dt_pre_update procedure controls the execution
190 -- of dml for the datetrack modes of: UPDATE, UPDATE_OVERRIDE
191 -- and UPDATE_CHANGE_INSERT only. The execution required is as
192 -- follows:
193 --
194 -- 1) Providing the datetrack update mode is not 'CORRECTION'
195 -- then set the effective end date of the current row (this
196 -- will be the validation_start_date - 1).
197 -- 2) If the datetrack mode is 'UPDATE_OVERRIDE' then call the
198 -- corresponding delete_dml process to delete any future rows
199 -- where the effective_start_date is greater than or equal to
200 -- the validation_start_date.
201 -- 3) Call the insert_dml process to insert the new updated row
202 -- details..
203 --
204 -- Pre Conditions:
205 -- This is an internal procedure which is called from the
206 -- pre_update procedure.
207 --
208 -- In Arguments:
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 -- This is an internal procedure which is required by Datetrack. Don't
219 -- remove or modify.
220 --
221 -- Access Status:
222 -- Internal Table Handler USe Only.
223 --
224 -- {End Of Comments}
225 -- ----------------------------------------------------------------------------
226 Procedure dt_pre_update
227 (p_rec in out nocopy pay_grr_shd.g_rec_type,
228 p_effective_date in date,
229 p_datetrack_mode in varchar2,
230 p_validation_start_date in date,
231 p_validation_end_date in date) is
232 --
233 l_proc varchar2(72) := g_package||'dt_pre_update';
234 l_dummy_version_number number;
235 --
236 Begin
237 hr_utility.set_location('Entering:'||l_proc, 5);
238 If (p_datetrack_mode <> 'CORRECTION') then
239 hr_utility.set_location(l_proc, 10);
240 --
241 -- Update the current effective end date
242 --
243 pay_grr_shd.upd_effective_end_date
244 (p_effective_date => p_effective_date,
245 p_base_key_value => p_rec.grade_rule_id,
246 p_new_effective_end_date => (p_validation_start_date - 1),
247 p_validation_start_date => p_validation_start_date,
248 p_validation_end_date => p_validation_end_date,
249 p_object_version_number => l_dummy_version_number);
250 --
251 If (p_datetrack_mode = 'UPDATE_OVERRIDE') then
252 hr_utility.set_location(l_proc, 15);
253 --
254 -- As the datetrack mode is 'UPDATE_OVERRIDE' then we must
255 -- delete any future rows
256 --
257 pay_grr_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 End If;
264 hr_utility.set_location(l_proc, 20);
265 --
266 -- We must now insert the updated row
267 --
268 pay_grr_ins.insert_dml
269 (p_rec => p_rec,
270 p_effective_date => p_effective_date,
271 p_datetrack_mode => p_datetrack_mode,
272 p_validation_start_date => p_validation_start_date,
273 p_validation_end_date => p_validation_end_date);
274 End If;
275 hr_utility.set_location(' Leaving:'||l_proc, 20);
276 End dt_pre_update;
277 --
278 -- ----------------------------------------------------------------------------
279 -- |------------------------------< pre_update >------------------------------|
280 -- ----------------------------------------------------------------------------
281 -- {Start Of Comments}
282 --
283 -- Description:
284 -- This private procedure contains any processing which is required before
285 -- the update dml.
286 --
287 -- Pre Conditions:
288 -- This is an internal procedure which is called from the upd procedure.
289 --
290 -- In Arguments:
291 -- A Pl/Sql record structre.
292 --
293 -- Post Success:
294 -- Processing continues.
295 --
296 -- Post Failure:
297 -- If an error has occurred, an error message and exception will be raised
298 -- but not handled.
299 --
300 -- Developer Implementation Notes:
301 -- Any pre-processing required before the update dml is issued should be
302 -- coded within this procedure. It is important to note that any 3rd party
303 -- maintenance should be reviewed before placing in this procedure. The call
304 -- to the dt_update_dml procedure should NOT be removed.
305 --
306 -- Access Status:
307 -- Internal Table Handler USe Only.
308 --
309 -- {End Of Comments}
310 -- ----------------------------------------------------------------------------
311 Procedure pre_update
312 (p_rec in out nocopy pay_grr_shd.g_rec_type,
313 p_effective_date in date,
314 p_datetrack_mode in varchar2,
315 p_validation_start_date in date,
316 p_validation_end_date in date) is
317 --
318 l_proc varchar2(72) := g_package||'pre_update';
319 --
320 Begin
321 hr_utility.set_location('Entering:'||l_proc, 5);
322 --
323 dt_pre_update
324 (p_rec => p_rec,
325 p_effective_date => p_effective_date,
326 p_datetrack_mode => p_datetrack_mode,
327 p_validation_start_date => p_validation_start_date,
328 p_validation_end_date => p_validation_end_date);
329 --
330 hr_utility.set_location(' Leaving:'||l_proc, 10);
331 End pre_update;
332 --
333 -- ----------------------------------------------------------------------------
334 -- |-----------------------------< post_update >------------------------------|
335 -- ----------------------------------------------------------------------------
336 -- {Start Of Comments}
337 --
338 -- Description:
339 -- This private procedure contains any processing which is required after the
340 -- update dml.
341 --
342 -- Pre Conditions:
343 -- This is an internal procedure which is called from the upd procedure.
344 --
345 -- In Arguments:
346 -- A Pl/Sql record structre.
347 --
348 -- Post Success:
349 -- Processing continues.
350 --
351 -- Post Failure:
352 -- If an error has occurred, an error message and exception will be raised
353 -- but not handled.
354 --
355 -- Developer Implementation Notes:
356 -- Any post-processing required after the update dml is issued should be
357 -- coded within this procedure. It is important to note that any 3rd party
358 -- maintenance should be reviewed before placing in this procedure.
359 --
360 -- Access Status:
361 -- Internal Table Handler USe Only.
362 --
363 -- {End Of Comments}
364 -- ----------------------------------------------------------------------------
365 Procedure post_update
366 (p_rec in pay_grr_shd.g_rec_type,
367 p_effective_date in date,
368 p_datetrack_mode in varchar2,
369 p_validation_start_date in date,
370 p_validation_end_date in date) is
371 --
372 l_proc varchar2(72) := g_package||'post_update';
373 --
374 Begin
375 hr_utility.set_location('Entering:'||l_proc, 5);
376 --
377 hr_utility.set_location(' Leaving:'||l_proc, 10);
378 End post_update;
379 --
380 -- ----------------------------------------------------------------------------
381 -- |-----------------------------< convert_defs >-----------------------------|
382 -- ----------------------------------------------------------------------------
383 -- {Start Of Comments}
384 --
385 -- Description:
386 -- The Convert_Defs procedure has one very important function:
387 -- It must return the record structure for the row with all system defaulted
388 -- values converted into its corresponding argument value for update. When
389 -- we attempt to update a row through the Upd business process , certain
390 -- arguments can be defaulted which enables flexibility in the calling of
391 -- the upd process (e.g. only attributes which need to be updated need to be
392 -- specified). For the upd business process to determine which attributes
393 -- have NOT been specified we need to check if the argument has a reserved
394 -- system default value. Therefore, for all attributes which have a
395 -- corresponding reserved system default mechanism specified we need to
396 -- check if a system default is being used. If a system default is being
397 -- used then we convert the defaulted value into its corresponding attribute
398 -- value held in the g_old_rec data structure.
399 --
400 -- Pre Conditions:
401 -- This private procedure can only be called from the upd process.
402 --
403 -- In Arguments:
404 -- p_rec
405 --
406 -- Post Success:
407 -- The record structure will be returned with all system defaulted argument
408 -- values converted into its current row attribute value.
409 --
410 -- Post Failure:
411 -- No direct error handling is required within this procedure. Any possible
412 -- errors within this procedure will be a PL/SQL value error due to
413 -- conversion of datatypes or data lengths.
414 --
415 -- Developer Implementation Notes:
416 -- None.
417 --
418 -- Access Status:
419 -- Internal Table Handler USe Only.
420 --
421 -- {End Of Comments}
422 -- ----------------------------------------------------------------------------
423 Procedure convert_defs(p_rec in out nocopy pay_grr_shd.g_rec_type) is
424 --
425 l_proc varchar2(72) := g_package||'convert_defs';
426 --
427 Begin
428 --
429 hr_utility.set_location('Entering:'||l_proc, 5);
430 --
431 -- We must now examine each argument value in the
432 -- p_rec plsql record structure
433 -- to see if a system default is being used. If a system default
434 -- is being used then we must set to the 'current' argument value.
435 --
436 If (p_rec.business_group_id = hr_api.g_number) then
437 p_rec.business_group_id :=
438 pay_grr_shd.g_old_rec.business_group_id;
439 End If;
440 If (p_rec.rate_id = hr_api.g_number) then
441 p_rec.rate_id :=
442 pay_grr_shd.g_old_rec.rate_id;
443 End If;
444 If (p_rec.grade_or_spinal_point_id = hr_api.g_number) then
445 p_rec.grade_or_spinal_point_id :=
446 pay_grr_shd.g_old_rec.grade_or_spinal_point_id;
447 End If;
448 If (p_rec.rate_type = hr_api.g_varchar2) then
449 p_rec.rate_type :=
450 pay_grr_shd.g_old_rec.rate_type;
451 End If;
452 If (p_rec.maximum = hr_api.g_varchar2) then
453 p_rec.maximum :=
454 pay_grr_shd.g_old_rec.maximum;
455 End If;
456 If (p_rec.mid_value = hr_api.g_varchar2) then
457 p_rec.mid_value :=
458 pay_grr_shd.g_old_rec.mid_value;
459 End If;
460 If (p_rec.minimum = hr_api.g_varchar2) then
461 p_rec.minimum :=
462 pay_grr_shd.g_old_rec.minimum;
463 End If;
464 If (p_rec.sequence = hr_api.g_number) then
465 p_rec.sequence :=
466 pay_grr_shd.g_old_rec.sequence;
467 End If;
468 If (p_rec.value = hr_api.g_varchar2) then
469 p_rec.value :=
470 pay_grr_shd.g_old_rec.value;
471 End If;
472 If (p_rec.request_id = hr_api.g_number) then
473 p_rec.request_id :=
474 pay_grr_shd.g_old_rec.request_id;
475 End If;
476 If (p_rec.program_application_id = hr_api.g_number) then
477 p_rec.program_application_id :=
478 pay_grr_shd.g_old_rec.program_application_id;
479 End If;
480 If (p_rec.program_id = hr_api.g_number) then
481 p_rec.program_id :=
482 pay_grr_shd.g_old_rec.program_id;
483 End If;
484 If (p_rec.program_update_date = hr_api.g_date) then
485 p_rec.program_update_date :=
486 pay_grr_shd.g_old_rec.program_update_date;
487 End If;
488 If (p_rec.currency_code = hr_api.g_varchar2) then
489 p_rec.currency_code :=
490 pay_grr_shd.g_old_rec.currency_code;
491 End If;
492 --
493 hr_utility.set_location(' Leaving:'||l_proc, 10);
494 --
495 End convert_defs;
496 --
497 -- ----------------------------------------------------------------------------
498 -- |---------------------------------< upd >----------------------------------|
499 -- ----------------------------------------------------------------------------
500 Procedure upd
501 (
502 p_rec in out nocopy pay_grr_shd.g_rec_type,
503 p_effective_date in date,
504 p_datetrack_mode in varchar2,
505 p_validate in boolean default false
506 ) is
507 --
508 l_proc varchar2(72) := g_package||'upd';
509 l_validation_start_date date;
510 l_validation_end_date date;
511 --
512 Begin
513 hr_utility.set_location('Entering:'||l_proc, 5);
514 --
515 -- Ensure that the DateTrack update mode is valid
516 --
517 dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode);
518 --
519 -- Determine if the business process is to be validated.
520 --
521 If p_validate then
522 --
523 -- Issue the savepoint.
524 --
525 SAVEPOINT upd_pay_grr;
526 End If;
527 --
528 -- We must lock the row which we need to update.
529 --
530 pay_grr_shd.lck
531 (p_effective_date => p_effective_date,
532 p_datetrack_mode => p_datetrack_mode,
533 p_grade_rule_id => p_rec.grade_rule_id,
534 p_object_version_number => p_rec.object_version_number,
535 p_validation_start_date => l_validation_start_date,
536 p_validation_end_date => l_validation_end_date);
537 --
538 -- 1. During an update system defaults are used to determine if
539 -- arguments have been defaulted or not. We must therefore
540 -- derive the full record structure values to be updated.
541 --
542 convert_defs(p_rec);
543 --
544 -- 2. Call the supporting update validate operations.
545 --
546 pay_grr_bus.update_validate
547 (p_rec => p_rec,
548 p_effective_date => p_effective_date,
549 p_datetrack_mode => p_datetrack_mode,
550 p_validation_start_date => l_validation_start_date,
551 p_validation_end_date => l_validation_end_date);
552 --
553 -- Call the supporting pre-update operation
554 --
555 pre_update
556 (p_rec => p_rec,
557 p_effective_date => p_effective_date,
558 p_datetrack_mode => p_datetrack_mode,
559 p_validation_start_date => l_validation_start_date,
560 p_validation_end_date => l_validation_end_date);
561 --
562 -- Update the row.
563 --
564 update_dml
565 (p_rec => p_rec,
566 p_effective_date => p_effective_date,
567 p_datetrack_mode => p_datetrack_mode,
568 p_validation_start_date => l_validation_start_date,
569 p_validation_end_date => l_validation_end_date);
570 --
571 -- Call the supporting post-update operation
572 --
573 post_update
574 (p_rec => p_rec,
575 p_effective_date => p_effective_date,
576 p_datetrack_mode => p_datetrack_mode,
577 p_validation_start_date => l_validation_start_date,
578 p_validation_end_date => l_validation_end_date);
579 --
580 -- If we are validating then raise the Validate_Enabled exception
581 --
582 If p_validate then
583 Raise HR_Api.Validate_Enabled;
584 End If;
585 --
586 hr_utility.set_location(' Leaving:'||l_proc, 10);
587 Exception
588 When HR_Api.Validate_Enabled Then
589 --
590 -- As the Validate_Enabled exception has been raised
591 -- we must rollback to the savepoint
592 --
593 ROLLBACK TO upd_pay_grr;
594 End upd;
595 --
596 -- ----------------------------------------------------------------------------
597 -- |---------------------------------< upd >----------------------------------|
598 -- ----------------------------------------------------------------------------
599 Procedure upd
600 (
601 p_grade_rule_id in number,
602 p_effective_start_date out nocopy date,
603 p_effective_end_date out nocopy date,
604 p_maximum in varchar2 default hr_api.g_varchar2,
605 p_mid_value in varchar2 default hr_api.g_varchar2,
606 p_minimum in varchar2 default hr_api.g_varchar2,
607 p_value in varchar2 default hr_api.g_varchar2,
608 p_request_id in number default hr_api.g_number,
609 p_program_application_id in number default hr_api.g_number,
610 p_program_id in number default hr_api.g_number,
611 p_program_update_date in date default hr_api.g_date,
612 p_object_version_number in out nocopy number,
613 p_effective_date in date,
614 p_datetrack_mode in varchar2,
615 p_validate in boolean default false,
616 p_currency_code in varchar2 default hr_api.g_varchar2
617 ) is
618 --
619 l_rec pay_grr_shd.g_rec_type;
620 l_proc varchar2(72) := g_package||'upd';
621 --
622 Begin
623 hr_utility.set_location('Entering:'||l_proc, 5);
624 --
625 -- Call conversion function to turn arguments into the
626 -- l_rec structure.
627 --
628 l_rec :=
629 pay_grr_shd.convert_args
630 (
631 p_grade_rule_id,
632 null,
633 null,
634 hr_api.g_number,
635 hr_api.g_number,
636 hr_api.g_number,
637 hr_api.g_varchar2,
638 p_maximum,
639 p_mid_value,
640 p_minimum,
641 hr_api.g_number,
642 p_value,
643 p_request_id,
644 p_program_application_id,
645 p_program_id,
646 p_program_update_date,
647 p_object_version_number,
648 p_currency_code
649 );
650 --
651 -- Having converted the arguments into the
652 -- plsql record structure we call the corresponding record
653 -- business process.
654 --
655 upd(l_rec, p_effective_date, p_datetrack_mode, p_validate);
656 p_object_version_number := l_rec.object_version_number;
657 p_effective_start_date := l_rec.effective_start_date;
658 p_effective_end_date := l_rec.effective_end_date;
659 --
660 --
661 hr_utility.set_location(' Leaving:'||l_proc, 10);
662 End upd;
663 --
664 end pay_grr_upd;