1 Package Body ame_acf_upd as
2 /* $Header: amacfrhi.pkb 120.5 2006/12/23 12:19:44 avarri noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ame_acf_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 ame_acf_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 ame_acf_shd.get_object_version_number
78 (p_action_type_id => p_rec.action_type_id
79 ,p_application_id => p_rec.application_id
80 );
81 --
82 --
83 --
84 -- Update the ame_action_type_config Row
85 --
86 update ame_action_type_config
87 set
88 application_id = p_rec.application_id
89 ,action_type_id = p_rec.action_type_id
90 ,voting_regime = p_rec.voting_regime
91 ,order_number = p_rec.order_number
92 ,chain_ordering_mode = p_rec.chain_ordering_mode
93 ,object_version_number = p_rec.object_version_number
94 where action_type_id = p_rec.action_type_id
95 and application_id = p_rec.application_id
96 and start_date = p_validation_start_date
97 and ((p_validation_end_date is null and end_date is null) or
98 (end_date = p_validation_end_date));
99 --
100 --
101 --
102 -- Set the effective start and end dates
103 --
104 p_rec.start_date := p_validation_start_date;
105 p_rec.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 --
113 ame_acf_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 --
118 ame_acf_shd.constraint_error
119 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
120 When Others Then
121 --
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 ame_acf_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 ame_acf_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 ame_acf_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 ame_acf_shd.upd_end_date
241 (p_effective_date => p_effective_date
242 ,p_action_type_id => p_rec.action_type_id
243 ,p_application_id => p_rec.application_id
244 ,p_new_end_date => p_validation_start_date
245 ,p_validation_start_date => p_validation_start_date
246 ,p_validation_end_date => p_validation_end_date
247 ,p_object_version_number => l_dummy_version_number
248 );
249 --
250 If (p_datetrack_mode = hr_api.g_update_override) then
251 --
252 -- As the datetrack mode is 'UPDATE_OVERRIDE' then we must
253 -- delete any future rows
254 --
255 ame_acf_del.delete_dml
256 (p_rec => p_rec
257 ,p_effective_date => p_effective_date
258 ,p_datetrack_mode => p_datetrack_mode
259 ,p_validation_start_date => p_validation_start_date
260 ,p_validation_end_date => p_validation_end_date
261 );
262 End If;
263 --
264 -- We must now insert the updated row
265 --
266 ame_acf_ins.insert_dml
267 (p_rec => p_rec
268 ,p_effective_date => p_effective_date
269 ,p_datetrack_mode => p_datetrack_mode
270 ,p_validation_start_date => p_validation_start_date
271 ,p_validation_end_date => p_validation_end_date
272 );
273 End If;
274 hr_utility.set_location(' Leaving:'||l_proc, 20);
275 End dt_pre_update;
276 --
277 -- ----------------------------------------------------------------------------
278 -- |------------------------------< pre_update >------------------------------|
279 -- ----------------------------------------------------------------------------
280 -- {Start Of Comments}
281 --
282 -- Description:
283 -- This private procedure contains any processing which is required before
284 -- the update dml.
285 --
286 -- Prerequisites:
287 -- This is an internal procedure which is called from the upd procedure.
288 --
289 -- In Parameters:
290 -- A Pl/Sql record structure.
291 --
292 -- Post Success:
293 -- Processing continues.
294 --
295 -- Post Failure:
296 -- If an error has occurred, an error message and exception will be raised
297 -- but not handled.
298 -- Developer Implementation Notes:
299 -- Any pre-processing required before the update dml is issued should be
300 -- coded within this procedure. It is important to note that any 3rd party
301 -- maintenance should be reviewed before placing in this procedure. The call
302 -- to the dt_update_dml procedure should NOT be removed.
303 --
304 -- Access Status:
305 -- Internal Row Handler Use Only.
306 --
307 -- {End Of Comments}
308 -- ----------------------------------------------------------------------------
309 Procedure pre_update
310 (p_rec in out nocopy ame_acf_shd.g_rec_type
311 ,p_effective_date in date
312 ,p_datetrack_mode in varchar2
313 ,p_validation_start_date in date
314 ,p_validation_end_date in date
315 ) is
316 --
317 l_proc varchar2(72) := g_package||'pre_update';
318 --
319 Begin
320 hr_utility.set_location('Entering:'||l_proc, 5);
321 --
322 --
323 --
324 dt_pre_update
325 (p_rec => p_rec
326 ,p_effective_date => p_effective_date
327 ,p_datetrack_mode => p_datetrack_mode
328 ,p_validation_start_date => p_validation_start_date
329 ,p_validation_end_date => p_validation_end_date
330 );
331 --
332 hr_utility.set_location(' Leaving:'||l_proc, 10);
333 End pre_update;
334 --
335 -- ----------------------------------------------------------------------------
336 -- |----------------------------< post_update >-------------------------------|
337 -- ----------------------------------------------------------------------------
338 -- {Start Of Comments}
339 --
340 -- Description:
341 -- This private procedure contains any processing which is required after
342 -- the update dml.
343 --
344 -- Prerequisites:
345 -- This is an internal procedure which is called from the upd procedure.
346 --
347 -- In Parameters:
348 -- A Pl/Sql record structure.
349 --
350 -- Post Success:
351 -- Processing continues.
352 --
353 -- Post Failure:
354 -- If an error has occurred, an error message and exception will be raised
355 -- but not handled.
356 --
357 -- Developer Implementation Notes:
358 -- Any post-processing required after the update dml is issued should be
359 -- coded within this procedure. It is important to note that any 3rd party
360 -- maintenance should be reviewed before placing in this procedure.
361 --
362 -- Access Status:
363 -- Internal Row Handler Use Only.
364 --
365 -- {End Of Comments}
366 -- ----------------------------------------------------------------------------
367 Procedure post_update
368 (p_rec in ame_acf_shd.g_rec_type
369 ,p_effective_date in date
370 ,p_datetrack_mode in varchar2
371 ,p_validation_start_date in date
372 ,p_validation_end_date in date
373 ) is
374 --
375 l_proc varchar2(72) := g_package||'post_update';
376 --
377 Begin
378 hr_utility.set_location('Entering:'||l_proc, 5);
379 begin
380 --
381 ame_acf_rku.after_update
382 (p_effective_date
383 => p_effective_date
384 ,p_datetrack_mode
385 => p_datetrack_mode
386 ,p_validation_start_date
387 => p_validation_start_date
388 ,p_validation_end_date
389 => p_validation_end_date
390 ,p_application_id
391 => p_rec.application_id
392 ,p_action_type_id
393 => p_rec.action_type_id
394 ,p_voting_regime
395 => p_rec.voting_regime
396 ,p_order_number
397 => p_rec.order_number
398 ,p_chain_ordering_mode
399 => p_rec.chain_ordering_mode
400 ,p_start_date
401 => p_rec.start_date
402 ,p_end_date
403 => p_rec.end_date
404 ,p_object_version_number
405 => p_rec.object_version_number
406 ,p_voting_regime_o
407 => ame_acf_shd.g_old_rec.voting_regime
408 ,p_order_number_o
409 => ame_acf_shd.g_old_rec.order_number
410 ,p_chain_ordering_mode_o
411 => ame_acf_shd.g_old_rec.chain_ordering_mode
412 ,p_start_date_o
413 => ame_acf_shd.g_old_rec.start_date
414 ,p_end_date_o
415 => ame_acf_shd.g_old_rec.end_date
416 ,p_object_version_number_o
417 => ame_acf_shd.g_old_rec.object_version_number
418 );
419 --
420 exception
421 --
422 when hr_api.cannot_find_prog_unit then
423 --
424 hr_api.cannot_find_prog_unit_error
425 (p_module_name => 'AME_ACTION_TYPE_CONFIG'
426 ,p_hook_type => 'AU');
427 --
428 end;
429 --
430 hr_utility.set_location(' Leaving:'||l_proc, 10);
431 End post_update;
432 --
433 -- ----------------------------------------------------------------------------
434 -- |-----------------------------< convert_defs >-----------------------------|
435 -- ----------------------------------------------------------------------------
436 -- {Start Of Comments}
437 --
438 -- Description:
439 -- The Convert_Defs procedure has one very important function:
440 -- It must return the record structure for the row with all system defaulted
441 -- values converted into its corresponding parameter value for update. When
442 -- we attempt to update a row through the Upd process , certain
443 -- parameters can be defaulted which enables flexibility in the calling of
444 -- the upd process (e.g. only attributes which need to be updated need to be
445 -- specified). For the upd process to determine which attributes
446 -- have NOT been specified we need to check if the parameter has a reserved
447 -- system default value. Therefore, for all parameters which have a
448 -- corresponding reserved system default mechanism specified we need to
449 -- check if a system default is being used. If a system default is being
450 -- used then we convert the defaulted value into its corresponding attribute
451 -- value held in the g_old_rec data structure.
452 --
453 -- Prerequisites:
454 -- This private function can only be called from the upd process.
455 --
456 -- In Parameters:
457 -- A Pl/Sql record structure.
458 --
459 -- Post Success:
460 -- The record structure will be returned with all system defaulted parameter
461 -- values converted into its current row attribute value.
462 --
463 -- Post Failure:
464 -- No direct error handling is required within this function. Any possible
465 -- errors within this procedure will be a PL/SQL value error due to
466 -- conversion of datatypes or data lengths.
467 --
468 -- Developer Implementation Notes:
469 -- None.
470 --
471 -- Access Status:
472 -- Internal Row Handler Use Only.
473 --
474 -- {End Of Comments}
475 -- ----------------------------------------------------------------------------
476 Procedure convert_defs
477 (p_rec in out nocopy ame_acf_shd.g_rec_type
478 ) is
479 --
480 Begin
481 --
482 -- We must now examine each argument value in the
483 -- p_rec plsql record structure
484 -- to see if a system default is being used. If a system default
485 -- is being used then we must set to the 'current' argument value.
486 --
487 If (p_rec.voting_regime = hr_api.g_varchar2) then
488 p_rec.voting_regime :=
489 ame_acf_shd.g_old_rec.voting_regime;
490 End If;
491 If (p_rec.order_number = hr_api.g_number) then
492 p_rec.order_number :=
493 ame_acf_shd.g_old_rec.order_number;
494 End If;
495 If (p_rec.chain_ordering_mode = hr_api.g_varchar2) then
496 p_rec.chain_ordering_mode :=
497 ame_acf_shd.g_old_rec.chain_ordering_mode;
498 End If;
499 --
500 End convert_defs;
501 --
502 -- ----------------------------------------------------------------------------
503 -- |---------------------------------< upd >----------------------------------|
504 -- ----------------------------------------------------------------------------
505 Procedure upd
506 (p_effective_date in date
507 ,p_datetrack_mode in varchar2
508 ,p_rec in out nocopy ame_acf_shd.g_rec_type
509 ) is
510 --
511 l_proc varchar2(72) := g_package||'upd';
512 l_validation_start_date date;
513 l_validation_end_date date;
514 --
515 Begin
516 hr_utility.set_location('Entering:'||l_proc, 5);
517 --
518 -- Ensure that the DateTrack update mode is valid
519 --
520 dt_api.validate_dt_upd_mode(p_datetrack_mode => p_datetrack_mode);
521 --
522 -- We must lock the row which we need to update.
523 --
524 ame_acf_shd.lck
525 (p_effective_date => p_effective_date
526 ,p_datetrack_mode => p_datetrack_mode
527 ,p_action_type_id => p_rec.action_type_id
528 ,p_application_id => p_rec.application_id
529 ,p_object_version_number => p_rec.object_version_number
530 ,p_validation_start_date => l_validation_start_date
531 ,p_validation_end_date => l_validation_end_date
532 );
533 --
534 -- 1. During an update system defaults are used to determine if
535 -- arguments have been defaulted or not. We must therefore
536 -- derive the full record structure values to be updated.
537 --
538 -- 2. Call the supporting update validate operations.
539 --
540 ame_acf_upd.convert_defs(p_rec);
541 --
542 ame_acf_bus.update_validate
543 (p_rec => p_rec
544 ,p_effective_date => p_effective_date
545 ,p_datetrack_mode => p_datetrack_mode
546 ,p_validation_start_date => l_validation_start_date
547 ,p_validation_end_date => l_validation_end_date
548 );
549 --
550 -- Call to raise any errors on multi-message list
551 hr_multi_message.end_validation_set;
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 --
563 -- Update the row.
564 --
565 update_dml
566 (p_rec => p_rec
567 ,p_effective_date => p_effective_date
568 ,p_datetrack_mode => p_datetrack_mode
569 ,p_validation_start_date => l_validation_start_date
570 ,p_validation_end_date => l_validation_end_date
571 );
572 --
573 -- Call the supporting post-update operation
574 --
575 post_update
576 (p_rec => p_rec
577 ,p_effective_date => p_effective_date
578 ,p_datetrack_mode => p_datetrack_mode
579 ,p_validation_start_date => l_validation_start_date
580 ,p_validation_end_date => l_validation_end_date
581 );
582 --
583 -- Call to raise any errors on multi-message list
584 hr_multi_message.end_validation_set;
585 End upd;
586 --
587 -- ----------------------------------------------------------------------------
588 -- |------------------------------< upd >-------------------------------------|
589 -- ----------------------------------------------------------------------------
590 Procedure upd
591 (p_effective_date in date
592 ,p_datetrack_mode in varchar2
593 ,p_application_id in number
594 ,p_action_type_id in number
595 ,p_object_version_number in out nocopy number
596 ,p_order_number in number default hr_api.g_number
597 ,p_voting_regime in varchar2 default hr_api.g_varchar2
598 ,p_chain_ordering_mode in varchar2 default hr_api.g_varchar2
599 ,p_start_date out nocopy date
600 ,p_end_date out nocopy date
601 ) is
602 --
603 l_rec ame_acf_shd.g_rec_type;
604 l_proc varchar2(72) := g_package||'upd';
605 --
606 Begin
607 hr_utility.set_location('Entering:'||l_proc, 5);
608 --
609 -- Call conversion function to turn arguments into the
610 -- l_rec structure.
611 --
612 l_rec :=
613 ame_acf_shd.convert_args
614 (p_application_id
615 ,p_action_type_id
616 ,p_voting_regime
617 ,p_order_number
618 ,p_chain_ordering_mode
619 ,null
620 ,null
621 ,p_object_version_number
622 );
623 --
624 -- Having converted the arguments into the
625 -- plsql record structure we call the corresponding record
626 -- business process.
627 --
628 ame_acf_upd.upd
629 (p_effective_date
630 ,p_datetrack_mode
631 ,l_rec
632 );
633 --
634 -- Set the out parameters
635 --
636 p_object_version_number := l_rec.object_version_number;
637 p_start_date := l_rec.start_date;
638 p_end_date := l_rec.end_date;
639 --
640 --
641 hr_utility.set_location(' Leaving:'||l_proc, 10);
642 End upd;
643 --
644 end ame_acf_upd;