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