DBA Data[Home] [Help]

PACKAGE BODY: APPS.AME_ATU_UPD

Source


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