DBA Data[Home] [Help]

PACKAGE BODY: APPS.AME_STV_UPD

Source


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