DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_SHA_UPD

Source


1 Package Body per_sha_upd as
2 /* $Header: pesharhi.pkb 115.6 2002/12/06 16:54:11 eumenyio ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  per_sha_upd.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------------< update_dml >------------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 --   This procedure controls the actual dml update logic. The processing of
17 --   this procedure is:
18 --   1) Increment the object_version_number by 1 if the object_version_number
19 --      is defined as an attribute for this entity.
20 --   3) To update the specified row in the schema using the primary key in
21 --      the predicates.
22 --   4) To trap any constraint violations that may have occurred.
23 --   5) To raise any other errors.
24 --
25 -- Prerequisites:
26 --   This is an internal private procedure which must be called from the upd
27 --   procedure.
28 --
29 -- In Parameters:
30 --   A Pl/Sql record structre.
31 --
32 -- Post Success:
33 --   The specified row will be updated in the schema.
34 --
35 -- Post Failure:
36 --   If a check, unique or parent integrity constraint violation is raised the
37 --   constraint_error procedure will be called.
38 --
39 -- Developer Implementation Notes:
40 --   The update 'set' attribute list should be modified if any of your
41 --   attributes are not updateable.
42 --
43 -- Access Status:
44 --   Internal Row Handler Use Only.
45 --
46 -- {End Of Comments}
47 -- ----------------------------------------------------------------------------
48 Procedure update_dml(p_rec in out nocopy per_sha_shd.g_rec_type) is
49 --
50   l_proc  varchar2(72) := g_package||'update_dml';
51 --
52 Begin
53   hr_utility.set_location('Entering:'||l_proc, 5);
54   --
55   -- Increment the object version
56   --
57   p_rec.object_version_number := p_rec.object_version_number + 1;
58   --
62   set
59   -- Update the per_std_holiday_absences Row
60   --
61   update per_std_holiday_absences
63   std_holiday_absences_id           = p_rec.std_holiday_absences_id,
64   date_not_taken                    = p_rec.date_not_taken,
65   person_id                         = p_rec.person_id,
66   standard_holiday_id               = p_rec.standard_holiday_id,
67   actual_date_taken                 = p_rec.actual_date_taken,
68   reason                            = p_rec.reason,
69   expired                           = p_rec.expired,
70   attribute_category                = p_rec.attribute_category,
71   attribute1                        = p_rec.attribute1,
72   attribute2                        = p_rec.attribute2,
73   attribute3                        = p_rec.attribute3,
74   attribute4                        = p_rec.attribute4,
75   attribute5                        = p_rec.attribute5,
76   attribute6                        = p_rec.attribute6,
77   attribute7                        = p_rec.attribute7,
78   attribute8                        = p_rec.attribute8,
79   attribute9                        = p_rec.attribute9,
80   attribute10                       = p_rec.attribute10,
81   attribute11                       = p_rec.attribute11,
82   attribute12                       = p_rec.attribute12,
83   attribute13                       = p_rec.attribute13,
84   attribute14                       = p_rec.attribute14,
85   attribute15                       = p_rec.attribute15,
86   attribute16                       = p_rec.attribute16,
87   attribute17                       = p_rec.attribute17,
88   attribute18                       = p_rec.attribute18,
89   attribute19                       = p_rec.attribute19,
90   attribute20                       = p_rec.attribute20,
91   object_version_number             = p_rec.object_version_number
92   where std_holiday_absences_id = p_rec.std_holiday_absences_id;
93   --
94   hr_utility.set_location(' Leaving:'||l_proc, 10);
95 --
96 Exception
97   When hr_api.check_integrity_violated Then
98     -- A check constraint has been violated
99     per_sha_shd.constraint_error
100       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
101   When hr_api.parent_integrity_violated Then
102     -- Parent integrity has been violated
103     per_sha_shd.constraint_error
104       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
105   When hr_api.unique_integrity_violated Then
106     -- Unique integrity has been violated
107     per_sha_shd.constraint_error
108       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
109   When Others Then
110     Raise;
111 End update_dml;
112 --
113 -- ----------------------------------------------------------------------------
114 -- |------------------------------< pre_update >------------------------------|
115 -- ----------------------------------------------------------------------------
116 -- {Start Of Comments}
117 --
118 -- Description:
119 --   This private procedure contains any processing which is required before
120 --   the update dml.
121 --
122 -- Prerequisites:
123 --   This is an internal procedure which is called from the upd procedure.
124 --
125 -- In Parameters:
126 --   A Pl/Sql record structre.
127 --
128 -- Post Success:
129 --   Processing continues.
130 --
131 -- Post Failure:
132 --   If an error has occurred, an error message and exception will be raised
133 --   but not handled.
134 --
135 -- Developer Implementation Notes:
136 --   Any pre-processing required before the update dml is issued should be
137 --   coded within this procedure. It is important to note that any 3rd party
138 --   maintenance should be reviewed before placing in this procedure.
139 --
140 -- Access Status:
141 --   Internal Row Handler Use Only.
142 --
143 -- {End Of Comments}
144 -- ----------------------------------------------------------------------------
145 Procedure pre_update(p_rec in per_sha_shd.g_rec_type) is
146 --
147   l_proc  varchar2(72) := g_package||'pre_update';
148 --
149 Begin
150   hr_utility.set_location('Entering:'||l_proc, 5);
151   --
152   hr_utility.set_location(' Leaving:'||l_proc, 10);
153 End pre_update;
154 --
155 -- ----------------------------------------------------------------------------
156 -- |-----------------------------< post_update >------------------------------|
157 -- ----------------------------------------------------------------------------
161 --   This private procedure contains any processing which is required after the
158 -- {Start Of Comments}
159 --
160 -- Description:
162 --   update dml.
163 --
164 -- Prerequisites:
165 --   This is an internal procedure which is called from the upd procedure.
166 --
167 -- In Parameters:
168 --   A Pl/Sql record structre.
169 --
170 -- Post Success:
171 --   Processing continues.
172 --
173 -- Post Failure:
174 --   If an error has occurred, an error message and exception will be raised
175 --   but not handled.
176 --
177 -- Developer Implementation Notes:
178 --   Any post-processing required after the update dml is issued should be
179 --   coded within this procedure. It is important to note that any 3rd party
180 --   maintenance should be reviewed before placing in this procedure.
181 --
182 -- Access Status:
183 --   Internal Row Handler Use Only.
184 --
185 -- {End Of Comments}
186 -- ----------------------------------------------------------------------------
187 Procedure post_update(p_rec in per_sha_shd.g_rec_type) is
188 --
189   l_proc  varchar2(72) := g_package||'post_update';
190 --
191 Begin
192   hr_utility.set_location('Entering:'||l_proc, 5);
193   --
194   --
195   -- Start of API User Hook for post_update.
196   begin
197     per_sha_rku.after_update
198     (p_std_holiday_absences_id  => p_rec.std_holiday_absences_id
199     ,p_date_not_taken           => p_rec.date_not_taken
200     ,p_person_id                => p_rec.person_id
201     ,p_standard_holiday_id      => p_rec.standard_holiday_id
202     ,p_actual_date_taken        => p_rec.actual_date_taken
203     ,p_reason                   => p_rec.reason
204     ,p_expired                  => p_rec.expired
205     ,p_attribute_category       => p_rec.attribute_category
206     ,p_attribute1               => p_rec.attribute1
207     ,p_attribute2               => p_rec.attribute2
208     ,p_attribute3               => p_rec.attribute3
209     ,p_attribute4               => p_rec.attribute4
210     ,p_attribute5               => p_rec.attribute5
211     ,p_attribute6               => p_rec.attribute6
212     ,p_attribute7               => p_rec.attribute7
213     ,p_attribute8               => p_rec.attribute8
214     ,p_attribute9               => p_rec.attribute9
215     ,p_attribute10              => p_rec.attribute10
216     ,p_attribute11              => p_rec.attribute11
217     ,p_attribute12              => p_rec.attribute12
218     ,p_attribute13              => p_rec.attribute13
219     ,p_attribute14              => p_rec.attribute14
220     ,p_attribute15              => p_rec.attribute15
221     ,p_attribute16              => p_rec.attribute16
222     ,p_attribute17              => p_rec.attribute17
223     ,p_attribute18              => p_rec.attribute18
224     ,p_attribute19              => p_rec.attribute19
225     ,p_attribute20              => p_rec.attribute20
226     ,p_object_version_number    => p_rec.object_version_number
227     ,p_date_not_taken_o         => per_sha_shd.g_old_rec.date_not_taken
228     ,p_person_id_o              => per_sha_shd.g_old_rec.person_id
229     ,p_standard_holiday_id_o    => per_sha_shd.g_old_rec.standard_holiday_id
230     ,p_actual_date_taken_o      => per_sha_shd.g_old_rec.actual_date_taken
231     ,p_reason_o                 => per_sha_shd.g_old_rec.reason
232     ,p_expired_o                => per_sha_shd.g_old_rec.expired
233     ,p_attribute_category_o     => per_sha_shd.g_old_rec.attribute_category
234     ,p_attribute1_o             => per_sha_shd.g_old_rec.attribute1
235     ,p_attribute2_o             => per_sha_shd.g_old_rec.attribute2
236     ,p_attribute3_o             => per_sha_shd.g_old_rec.attribute3
237     ,p_attribute4_o             => per_sha_shd.g_old_rec.attribute4
238     ,p_attribute5_o             => per_sha_shd.g_old_rec.attribute5
239     ,p_attribute6_o             => per_sha_shd.g_old_rec.attribute6
240     ,p_attribute7_o             => per_sha_shd.g_old_rec.attribute7
241     ,p_attribute8_o             => per_sha_shd.g_old_rec.attribute8
242     ,p_attribute9_o             => per_sha_shd.g_old_rec.attribute9
243     ,p_attribute10_o            => per_sha_shd.g_old_rec.attribute10
244     ,p_attribute11_o            => per_sha_shd.g_old_rec.attribute11
245     ,p_attribute12_o            => per_sha_shd.g_old_rec.attribute12
246     ,p_attribute13_o            => per_sha_shd.g_old_rec.attribute13
247     ,p_attribute14_o            => per_sha_shd.g_old_rec.attribute14
248     ,p_attribute15_o            => per_sha_shd.g_old_rec.attribute15
249     ,p_attribute16_o            => per_sha_shd.g_old_rec.attribute16
250     ,p_attribute17_o            => per_sha_shd.g_old_rec.attribute17
251     ,p_attribute18_o            => per_sha_shd.g_old_rec.attribute18
252     ,p_attribute19_o            => per_sha_shd.g_old_rec.attribute19
253     ,p_attribute20_o            => per_sha_shd.g_old_rec.attribute20
254     ,p_object_version_number_o  => per_sha_shd.g_old_rec.object_version_number
255     );
256   exception
257     when hr_api.cannot_find_prog_unit then
258       hr_api.cannot_find_prog_unit_error
259         (p_module_name => 'PER_STD_HOLIDAY_ABSENCES'
260         ,p_hook_type   => 'AU'
261         );
262   end;
263   -- End of API User Hook for post_update.
264   hr_utility.set_location(' Leaving:'||l_proc, 10);
265 End post_update;
266 --
267 -- ----------------------------------------------------------------------------
268 -- |-----------------------------< convert_defs >-----------------------------|
269 -- ----------------------------------------------------------------------------
270 -- {Start Of Comments}
271 --
272 -- Description:
273 --   The Convert_Defs procedure has one very important function:
274 --   It must return the record structure for the row with all system defaulted
275 --   values converted into its corresponding parameter value for update. When
276 --   we attempt to update a row through the Upd process , certain
277 --   parameters can be defaulted which enables flexibility in the calling of
278 --   the upd process (e.g. only attributes which need to be updated need to be
279 --   specified). For the upd process to determine which attributes
280 --   have NOT been specified we need to check if the parameter has a reserved
281 --   system default value. Therefore, for all parameters which have a
282 --   corresponding reserved system default mechanism specified we need to
283 --   check if a system default is being used. If a system default is being
284 --   used then we convert the defaulted value into its corresponding attribute
285 --   value held in the g_old_rec data structure.
286 --
287 -- Prerequisites:
288 --   This private function can only be called from the upd process.
289 --
290 -- In Parameters:
291 --   A Pl/Sql record structre.
292 --
293 -- Post Success:
294 --   The record structure will be returned with all system defaulted parameter
295 --   values converted into its current row attribute value.
296 --
297 -- Post Failure:
298 --   No direct error handling is required within this function. Any possible
299 --   errors within this procedure will be a PL/SQL value error due to conversion
300 
301 --   of datatypes or data lengths.
302 --
303 -- Developer Implementation Notes:
304 --   None.
305 --
306 -- Access Status:
307 --   Internal Row Handler Use Only.
308 --
309 -- {End Of Comments}
310 -- ----------------------------------------------------------------------------
311 Procedure convert_defs(p_rec in out nocopy per_sha_shd.g_rec_type) is
312 --
313   l_proc  varchar2(72) := g_package||'convert_defs';
314 --
315 Begin
316   --
317   hr_utility.set_location('Entering:'||l_proc, 5);
318   --
319   -- We must now examine each argument value in the
320   -- p_rec plsql record structure
321   -- to see if a system default is being used. If a system default
322   -- is being used then we must set to the 'current' argument value.
323   --
324   If (p_rec.date_not_taken = hr_api.g_date) then
325     p_rec.date_not_taken :=
326     per_sha_shd.g_old_rec.date_not_taken;
327   End If;
328   If (p_rec.person_id = hr_api.g_number) then
329     p_rec.person_id :=
330     per_sha_shd.g_old_rec.person_id;
331   End If;
332   If (p_rec.standard_holiday_id = hr_api.g_number) then
333     p_rec.standard_holiday_id :=
334     per_sha_shd.g_old_rec.standard_holiday_id;
335   End If;
336   If (p_rec.actual_date_taken = hr_api.g_date) then
337     p_rec.actual_date_taken :=
338     per_sha_shd.g_old_rec.actual_date_taken;
339   End If;
340   If (p_rec.reason = hr_api.g_varchar2) then
341     p_rec.reason :=
342     per_sha_shd.g_old_rec.reason;
343   End If;
344   If (p_rec.expired = hr_api.g_varchar2) then
345     p_rec.expired :=
346     per_sha_shd.g_old_rec.expired;
347   End If;
348   If (p_rec.attribute_category = hr_api.g_varchar2) then
349     p_rec.attribute_category :=
350     per_sha_shd.g_old_rec.attribute_category;
351   End If;
352   If (p_rec.attribute1 = hr_api.g_varchar2) then
353     p_rec.attribute1 :=
354     per_sha_shd.g_old_rec.attribute1;
355   End If;
356   If (p_rec.attribute2 = hr_api.g_varchar2) then
357     p_rec.attribute2 :=
358     per_sha_shd.g_old_rec.attribute2;
359   End If;
360   If (p_rec.attribute3 = hr_api.g_varchar2) then
361     p_rec.attribute3 :=
362     per_sha_shd.g_old_rec.attribute3;
363   End If;
364   If (p_rec.attribute4 = hr_api.g_varchar2) then
365     p_rec.attribute4 :=
366     per_sha_shd.g_old_rec.attribute4;
367   End If;
368   If (p_rec.attribute5 = hr_api.g_varchar2) then
369     p_rec.attribute5 :=
370     per_sha_shd.g_old_rec.attribute5;
371   End If;
372   If (p_rec.attribute6 = hr_api.g_varchar2) then
373     p_rec.attribute6 :=
374     per_sha_shd.g_old_rec.attribute6;
375   End If;
376   If (p_rec.attribute7 = hr_api.g_varchar2) then
377     p_rec.attribute7 :=
378     per_sha_shd.g_old_rec.attribute7;
379   End If;
380   If (p_rec.attribute8 = hr_api.g_varchar2) then
381     p_rec.attribute8 :=
382     per_sha_shd.g_old_rec.attribute8;
383   End If;
384   If (p_rec.attribute9 = hr_api.g_varchar2) then
385     p_rec.attribute9 :=
386     per_sha_shd.g_old_rec.attribute9;
387   End If;
388   If (p_rec.attribute10 = hr_api.g_varchar2) then
389     p_rec.attribute10 :=
393     p_rec.attribute11 :=
390     per_sha_shd.g_old_rec.attribute10;
391   End If;
392   If (p_rec.attribute11 = hr_api.g_varchar2) then
394     per_sha_shd.g_old_rec.attribute11;
395   End If;
396   If (p_rec.attribute12 = hr_api.g_varchar2) then
397     p_rec.attribute12 :=
398     per_sha_shd.g_old_rec.attribute12;
399   End If;
400   If (p_rec.attribute13 = hr_api.g_varchar2) then
401     p_rec.attribute13 :=
402     per_sha_shd.g_old_rec.attribute13;
403   End If;
404   If (p_rec.attribute14 = hr_api.g_varchar2) then
405     p_rec.attribute14 :=
406     per_sha_shd.g_old_rec.attribute14;
407   End If;
408   If (p_rec.attribute15 = hr_api.g_varchar2) then
409     p_rec.attribute15 :=
410     per_sha_shd.g_old_rec.attribute15;
411   End If;
412   If (p_rec.attribute16 = hr_api.g_varchar2) then
413     p_rec.attribute16 :=
414     per_sha_shd.g_old_rec.attribute16;
415   End If;
416   If (p_rec.attribute17 = hr_api.g_varchar2) then
417     p_rec.attribute17 :=
418     per_sha_shd.g_old_rec.attribute17;
419   End If;
420   If (p_rec.attribute18 = hr_api.g_varchar2) then
421     p_rec.attribute18 :=
422     per_sha_shd.g_old_rec.attribute18;
423   End If;
424   If (p_rec.attribute19 = hr_api.g_varchar2) then
425     p_rec.attribute19 :=
426     per_sha_shd.g_old_rec.attribute19;
427   End If;
428   If (p_rec.attribute20 = hr_api.g_varchar2) then
429     p_rec.attribute20 :=
430     per_sha_shd.g_old_rec.attribute20;
431   End If;
432 
433   --
434   hr_utility.set_location(' Leaving:'||l_proc, 10);
435 --
436 End convert_defs;
437 --
438 -- ----------------------------------------------------------------------------
439 -- |---------------------------------< upd >----------------------------------|
440 -- ----------------------------------------------------------------------------
441 Procedure upd
442   (
443   p_rec        in out nocopy per_sha_shd.g_rec_type
444   ) is
445 --
446   l_proc  varchar2(72) := g_package||'upd';
447 --
448 Begin
449   hr_utility.set_location('Entering:'||l_proc, 5);
450   --
451   -- We must lock the row which we need to update.
452   --
453   per_sha_shd.lck
454 	(
455 	p_rec.std_holiday_absences_id,
456 	p_rec.object_version_number
457 	);
458   --
459   -- 1. During an update system defaults are used to determine if
460   --    arguments have been defaulted or not. We must therefore
461   --    derive the full record structure values to be updated.
462   --
463   -- 2. Call the supporting update validate operations.
464   --
465   convert_defs(p_rec);
466   per_sha_bus.update_validate(p_rec);
467   --
468   -- Call the supporting pre-update operation
469   --
470   pre_update(p_rec);
471   --
472   -- Update the row.
473   --
474   update_dml(p_rec);
475   --
476   -- Call the supporting post-update operation
477   --
478   post_update(p_rec);
479 End upd;
480 --
481 -- ----------------------------------------------------------------------------
482 -- |---------------------------------< upd >----------------------------------|
483 -- ----------------------------------------------------------------------------
484 Procedure upd
485   (
486   p_std_holiday_absences_id      in number,
487   p_date_not_taken               in date             default hr_api.g_date,
488   p_person_id                    in number           default hr_api.g_number,
489   p_standard_holiday_id          in number           default hr_api.g_number,
490   p_actual_date_taken            in date             default hr_api.g_date,
491   p_reason                       in varchar2         default hr_api.g_varchar2,
492   p_expired                      in varchar2         default hr_api.g_varchar2,
493   p_attribute_category           in varchar2         default hr_api.g_varchar2,
494   p_attribute1                   in varchar2         default hr_api.g_varchar2,
495   p_attribute2                   in varchar2         default hr_api.g_varchar2,
496   p_attribute3                   in varchar2         default hr_api.g_varchar2,
497   p_attribute4                   in varchar2         default hr_api.g_varchar2,
498   p_attribute5                   in varchar2         default hr_api.g_varchar2,
499   p_attribute6                   in varchar2         default hr_api.g_varchar2,
500   p_attribute7                   in varchar2         default hr_api.g_varchar2,
501   p_attribute8                   in varchar2         default hr_api.g_varchar2,
502   p_attribute9                   in varchar2         default hr_api.g_varchar2,
503   p_attribute10                  in varchar2         default hr_api.g_varchar2,
504   p_attribute11                  in varchar2         default hr_api.g_varchar2,
505   p_attribute12                  in varchar2         default hr_api.g_varchar2,
506   p_attribute13                  in varchar2         default hr_api.g_varchar2,
507   p_attribute14                  in varchar2         default hr_api.g_varchar2,
508   p_attribute15                  in varchar2         default hr_api.g_varchar2,
509   p_attribute16                  in varchar2         default hr_api.g_varchar2,
510   p_attribute17                  in varchar2         default hr_api.g_varchar2,
511   p_attribute18                  in varchar2         default hr_api.g_varchar2,
512   p_attribute19                  in varchar2         default hr_api.g_varchar2,
513   p_attribute20                  in varchar2         default hr_api.g_varchar2,
514   p_object_version_number        in out nocopy number
515   ) is
516 --
517   l_rec	  per_sha_shd.g_rec_type;
518   l_proc  varchar2(72) := g_package||'upd';
519 --
520 Begin
521   hr_utility.set_location('Entering:'||l_proc, 5);
522   --
523   -- Call conversion function to turn arguments into the
524   -- l_rec structure.
525   --
526   l_rec :=
527   per_sha_shd.convert_args
528   (
529   p_std_holiday_absences_id,
530   p_date_not_taken,
531   p_person_id,
532   p_standard_holiday_id,
533   p_actual_date_taken,
534   p_reason,
535   p_expired,
536   p_attribute_category,
537   p_attribute1,
538   p_attribute2,
539   p_attribute3,
540   p_attribute4,
541   p_attribute5,
542   p_attribute6,
543   p_attribute7,
544   p_attribute8,
545   p_attribute9,
546   p_attribute10,
547   p_attribute11,
548   p_attribute12,
549   p_attribute13,
550   p_attribute14,
551   p_attribute15,
552   p_attribute16,
553   p_attribute17,
554   p_attribute18,
555   p_attribute19,
556   p_attribute20,
557   p_object_version_number
558   );
559   --
560   -- Having converted the arguments into the
561   -- plsql record structure we call the corresponding record
562   -- business process.
563   --
564   upd(l_rec);
565   p_object_version_number := l_rec.object_version_number;
566   --
567   hr_utility.set_location(' Leaving:'||l_proc, 10);
568 End upd;
569 --
570 end per_sha_upd;