DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_RET_UPD

Source


1 Package Body per_ret_upd as
2 /* $Header: peretrhi.pkb 115.1 2002/12/06 11:29:20 eumenyio noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  per_ret_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 --   2) To set and unset the g_api_dml status as required (as we are about to
21 --      perform dml).
22 --   3) To update the specified row in the schema using the primary key in
23 --      the predicates.
24 --   4) To trap any constraint violations that may have occurred.
25 --   5) To raise any other errors.
26 --
27 -- Prerequisites:
28 --   This is an internal private procedure which must be called from the upd
29 --   procedure.
30 --
31 -- In Parameters:
32 --   A Pl/Sql record structre.
33 --
34 -- Post Success:
35 --   The specified row will be updated in the schema.
36 --
37 -- Post Failure:
38 --   On the update dml failure it is important to note that we always reset the
39 --   g_api_dml status to false.
40 --   If a check, unique or parent integrity constraint violation is raised the
41 --   constraint_error procedure will be called.
42 --   If any other error is reported, the error will be raised after the
43 --   g_api_dml status is reset.
44 --
45 -- Developer Implementation Notes:
46 --   The update 'set' attribute list should be modified if any of your
47 --   attributes are not updateable.
48 --
49 -- Access Status:
50 --   Internal Row Handler Use Only.
51 --
52 -- {End Of Comments}
53 -- ----------------------------------------------------------------------------
54 Procedure update_dml
55   (p_rec in out nocopy per_ret_shd.g_rec_type
56   ) is
57 --
58   l_proc  varchar2(72) := g_package||'update_dml';
59 --
60 Begin
61   hr_utility.set_location('Entering:'||l_proc, 5);
62   --
63   -- Increment the object version
64   p_rec.object_version_number := p_rec.object_version_number + 1;
65   --
66   --
67   --
68   -- Update the per_cagr_retained_rights Row
69   --
70   update per_cagr_retained_rights
71     set
72     cagr_retained_right_id          = p_rec.cagr_retained_right_id
73     ,freeze_flag                     = p_rec.freeze_flag
74     ,end_date                        = p_rec.end_date
75     ,object_version_number           = p_rec.object_version_number
76     where cagr_retained_right_id = p_rec.cagr_retained_right_id;
77   --
78   --
79   --
80   hr_utility.set_location(' Leaving:'||l_proc, 10);
81 --
82 Exception
83   When hr_api.check_integrity_violated Then
84     -- A check constraint has been violated
85     --
86     per_ret_shd.constraint_error
87       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
88   When hr_api.parent_integrity_violated Then
89     -- Parent integrity has been violated
90     --
91     per_ret_shd.constraint_error
92       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
93   When hr_api.unique_integrity_violated Then
94     -- Unique integrity has been violated
95     --
96     per_ret_shd.constraint_error
97       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
98   When Others Then
99     --
100     Raise;
101 End update_dml;
102 --
103 -- ----------------------------------------------------------------------------
104 -- |------------------------------< pre_update >------------------------------|
105 -- ----------------------------------------------------------------------------
106 -- {Start Of Comments}
107 --
108 -- Description:
109 --   This private procedure contains any processing which is required before
110 --   the update dml.
111 --
112 -- Prerequisites:
113 --   This is an internal procedure which is called from the upd procedure.
114 --
115 -- In Parameters:
116 --   A Pl/Sql record structure.
117 --
118 -- Post Success:
119 --   Processing continues.
120 --
121 -- Post Failure:
122 --   If an error has occurred, an error message and exception wil be raised
123 --   but not handled.
124 --
125 -- Developer Implementation Notes:
126 --   Any pre-processing required before the update dml is issued should be
127 --   coded within this procedure. It is important to note that any 3rd party
128 --   maintenance should be reviewed before placing in this procedure.
129 --
130 -- Access Status:
131 --   Internal Row Handler Use Only.
132 --
133 -- {End Of Comments}
134 -- ----------------------------------------------------------------------------
135 Procedure pre_update
136   (p_rec in per_ret_shd.g_rec_type
137   ) is
138 --
139   l_proc  varchar2(72) := g_package||'pre_update';
140 --
141 Begin
142   hr_utility.set_location('Entering:'||l_proc, 5);
143   --
144   hr_utility.set_location(' Leaving:'||l_proc, 10);
145 End pre_update;
146 --
147 -- ----------------------------------------------------------------------------
148 -- |-----------------------------< post_update >------------------------------|
149 -- ----------------------------------------------------------------------------
150 -- {Start Of Comments}
151 --
152 -- Description:
153 --   This private procedure contains any processing which is required after
154 --   the update dml.
155 --
156 -- Prerequisites:
157 --   This is an internal procedure which is called from the upd procedure.
158 --
159 -- In Parameters:
160 --   A Pl/Sql record structure.
161 --
162 -- Post Success:
163 --   Processing continues.
164 --
165 -- Post Failure:
166 --   If an error has occurred, an error message and exception will be raised
167 --   but not handled.
168 --
169 -- Developer Implementation Notes:
170 --   Any post-processing required after the update dml is issued should be
171 --   coded within this procedure. It is important to note that any 3rd party
172 --   maintenance should be reviewed before placing in this procedure.
173 --
174 -- Access Status:
175 --   Internal Row Handler Use Only.
176 --
177 -- {End Of Comments}
178 -- ----------------------------------------------------------------------------
179 Procedure post_update
180   (p_effective_date               in date
181   ,p_rec                          in per_ret_shd.g_rec_type
182   ) is
183 --
184   l_proc  varchar2(72) := g_package||'post_update';
185 --
186 Begin
187   hr_utility.set_location('Entering:'||l_proc, 5);
188 /*
189   begin
190     --
191     per_ret_rku.after_update
192       (p_effective_date              => p_effective_date
193       ,p_cagr_retained_right_id
194       => p_rec.cagr_retained_right_id
195       ,p_freeze_flag
196       => p_rec.freeze_flag
197       ,p_end_date
198       => p_rec.end_date
199       ,p_object_version_number
200       => p_rec.object_version_number
201       ,p_assignment_id_o
202       => per_ret_shd.g_old_rec.assignment_id
203       ,p_cagr_entitlement_item_id_o
204       => per_ret_shd.g_old_rec.cagr_entitlement_item_id
205       ,p_collective_agreement_id_o
206       => per_ret_shd.g_old_rec.collective_agreement_id
207       ,p_cagr_entitlement_id_o
208       => per_ret_shd.g_old_rec.cagr_entitlement_id
209       ,p_category_name_o
210       => per_ret_shd.g_old_rec.category_name
211       ,p_element_type_id_o
212       => per_ret_shd.g_old_rec.element_type_id
213       ,p_input_value_id_o
214       => per_ret_shd.g_old_rec.input_value_id
215       ,p_cagr_api_id_o
216       => per_ret_shd.g_old_rec.cagr_api_id
217       ,p_cagr_api_param_id_o
218       => per_ret_shd.g_old_rec.cagr_api_param_id
219       ,p_cagr_entitlement_line_id_o
220       => per_ret_shd.g_old_rec.cagr_entitlement_line_id
221       ,p_freeze_flag_o
222       => per_ret_shd.g_old_rec.freeze_flag
223       ,p_value_o
224       => per_ret_shd.g_old_rec.value
225       ,p_units_of_measure_o
226       => per_ret_shd.g_old_rec.units_of_measure
227       ,p_start_date_o
228       => per_ret_shd.g_old_rec.start_date
229       ,p_end_date_o
230       => per_ret_shd.g_old_rec.end_date
231       ,p_parent_spine_id_o
232       => per_ret_shd.g_old_rec.parent_spine_id
233       ,p_formula_id_o
234       => per_ret_shd.g_old_rec.formula_id
235       ,p_oipl_id_o
236       => per_ret_shd.g_old_rec.oipl_id
237       ,p_step_id_o
238       => per_ret_shd.g_old_rec.step_id
239       ,p_grade_spine_id_o
240       => per_ret_shd.g_old_rec.grade_spine_id
241       ,p_column_type_o
242       => per_ret_shd.g_old_rec.column_type
243       ,p_column_size_o
244       => per_ret_shd.g_old_rec.column_size
245       ,p_eligy_prfl_id_o
246       => per_ret_shd.g_old_rec.eligy_prfl_id
247       ,p_object_version_number_o
248       => per_ret_shd.g_old_rec.object_version_number
249       ,p_cagr_entitlement_result_id_o
250       => per_ret_shd.g_old_rec.cagr_entitlement_result_id
251       ,p_business_group_id_o
252       => per_ret_shd.g_old_rec.business_group_id
253       ,p_flex_value_set_id_o
254       => per_ret_shd.g_old_rec.flex_value_set_id
255       );
256     --
257   exception
258     --
259     when hr_api.cannot_find_prog_unit then
260       --
261       hr_api.cannot_find_prog_unit_error
262         (p_module_name => 'PER_CAGR_RETAINED_RIGHTS'
263         ,p_hook_type   => 'AU');
264       --
265   end;
266 */
267   --
268   hr_utility.set_location(' Leaving:'||l_proc, 10);
269 End post_update;
270 --
271 -- ----------------------------------------------------------------------------
272 -- |-----------------------------< convert_defs >-----------------------------|
273 -- ----------------------------------------------------------------------------
274 -- {Start Of Comments}
275 --
276 -- Description:
277 --   The Convert_Defs procedure has one very important function:
278 --   It must return the record structure for the row with all system defaulted
279 --   values converted into its corresponding parameter value for update. When
280 --   we attempt to update a row through the Upd process , certain
281 --   parameters can be defaulted which enables flexibility in the calling of
282 --   the upd process (e.g. only attributes which need to be updated need to be
283 --   specified). For the upd process to determine which attributes
284 --   have NOT been specified we need to check if the parameter has a reserved
285 --   system default value. Therefore, for all parameters which have a
286 --   corresponding reserved system default mechanism specified we need to
287 --   check if a system default is being used. If a system default is being
288 --   used then we convert the defaulted value into its corresponding attribute
289 --   value held in the g_old_rec data structure.
290 --
291 -- Prerequisites:
292 --   This private function can only be called from the upd process.
293 --
294 -- In Parameters:
295 --   A Pl/Sql record structure.
296 --
297 -- Post Success:
298 --   The record structure will be returned with all system defaulted parameter
299 --   values converted into its current row attribute value.
300 --
301 -- Post Failure:
302 --   No direct error handling is required within this function. Any possible
303 --   errors within this procedure will be a PL/SQL value error due to
304 --   conversion of datatypes or data lengths.
305 --
306 -- Developer Implementation Notes:
307 --   None.
308 --
309 -- Access Status:
310 --   Internal Row Handler Use Only.
311 --
312 -- {End Of Comments}
313 -- ----------------------------------------------------------------------------
314 Procedure convert_defs
315   (p_rec in out nocopy per_ret_shd.g_rec_type
316   ) is
317 --
318 Begin
319   --
320   -- We must now examine each argument value in the
321   -- p_rec plsql record structure
322   -- to see if a system default is being used. If a system default
323   -- is being used then we must set to the 'current' argument value.
324   --
325   If (p_rec.assignment_id = hr_api.g_number) then
326     p_rec.assignment_id :=
327     per_ret_shd.g_old_rec.assignment_id;
328   End If;
329   If (p_rec.cagr_entitlement_item_id = hr_api.g_number) then
330     p_rec.cagr_entitlement_item_id :=
331     per_ret_shd.g_old_rec.cagr_entitlement_item_id;
332   End If;
333   If (p_rec.collective_agreement_id = hr_api.g_number) then
334     p_rec.collective_agreement_id :=
335     per_ret_shd.g_old_rec.collective_agreement_id;
336   End If;
337   If (p_rec.cagr_entitlement_id = hr_api.g_number) then
338     p_rec.cagr_entitlement_id :=
339     per_ret_shd.g_old_rec.cagr_entitlement_id;
340   End If;
341   If (p_rec.category_name = hr_api.g_varchar2) then
342     p_rec.category_name :=
343     per_ret_shd.g_old_rec.category_name;
344   End If;
345   If (p_rec.element_type_id = hr_api.g_number) then
346     p_rec.element_type_id :=
347     per_ret_shd.g_old_rec.element_type_id;
348   End If;
349   If (p_rec.input_value_id = hr_api.g_number) then
350     p_rec.input_value_id :=
351     per_ret_shd.g_old_rec.input_value_id;
352   End If;
353   If (p_rec.cagr_api_id = hr_api.g_number) then
354     p_rec.cagr_api_id :=
355     per_ret_shd.g_old_rec.cagr_api_id;
356   End If;
357   If (p_rec.cagr_api_param_id = hr_api.g_number) then
358     p_rec.cagr_api_param_id :=
359     per_ret_shd.g_old_rec.cagr_api_param_id;
360   End If;
361   If (p_rec.cagr_entitlement_line_id = hr_api.g_number) then
362     p_rec.cagr_entitlement_line_id :=
363     per_ret_shd.g_old_rec.cagr_entitlement_line_id;
364   End If;
365   If (p_rec.freeze_flag = hr_api.g_varchar2) then
366     p_rec.freeze_flag :=
367     per_ret_shd.g_old_rec.freeze_flag;
368   End If;
369   If (p_rec.value = hr_api.g_varchar2) then
370     p_rec.value :=
371     per_ret_shd.g_old_rec.value;
372   End If;
373   If (p_rec.units_of_measure = hr_api.g_varchar2) then
374     p_rec.units_of_measure :=
375     per_ret_shd.g_old_rec.units_of_measure;
376   End If;
377   If (p_rec.start_date = hr_api.g_date) then
378     p_rec.start_date :=
379     per_ret_shd.g_old_rec.start_date;
380   End If;
381   If (p_rec.end_date = hr_api.g_date) then
382     p_rec.end_date :=
383     per_ret_shd.g_old_rec.end_date;
384   End If;
385   If (p_rec.parent_spine_id = hr_api.g_number) then
386     p_rec.parent_spine_id :=
387     per_ret_shd.g_old_rec.parent_spine_id;
388   End If;
389   If (p_rec.formula_id = hr_api.g_number) then
390     p_rec.formula_id :=
391     per_ret_shd.g_old_rec.formula_id;
392   End If;
393   If (p_rec.oipl_id = hr_api.g_number) then
394     p_rec.oipl_id :=
395     per_ret_shd.g_old_rec.oipl_id;
396   End If;
397   If (p_rec.step_id = hr_api.g_number) then
398     p_rec.step_id :=
399     per_ret_shd.g_old_rec.step_id;
400   End If;
401   If (p_rec.grade_spine_id = hr_api.g_number) then
402     p_rec.grade_spine_id :=
403     per_ret_shd.g_old_rec.grade_spine_id;
404   End If;
405   If (p_rec.column_type = hr_api.g_varchar2) then
406     p_rec.column_type :=
407     per_ret_shd.g_old_rec.column_type;
408   End If;
409   If (p_rec.column_size = hr_api.g_number) then
410     p_rec.column_size :=
411     per_ret_shd.g_old_rec.column_size;
412   End If;
413   If (p_rec.eligy_prfl_id = hr_api.g_number) then
414     p_rec.eligy_prfl_id :=
415     per_ret_shd.g_old_rec.eligy_prfl_id;
416   End If;
417   If (p_rec.cagr_entitlement_result_id = hr_api.g_number) then
418     p_rec.cagr_entitlement_result_id :=
419     per_ret_shd.g_old_rec.cagr_entitlement_result_id;
420   End If;
421   If (p_rec.business_group_id = hr_api.g_number) then
422     p_rec.business_group_id :=
423     per_ret_shd.g_old_rec.business_group_id;
424   End If;
425   If (p_rec.flex_value_set_id = hr_api.g_number) then
426     p_rec.flex_value_set_id :=
427     per_ret_shd.g_old_rec.flex_value_set_id;
428   End If;
429   --
430 End convert_defs;
431 --
432 -- ----------------------------------------------------------------------------
433 -- |---------------------------------< upd >----------------------------------|
434 -- ----------------------------------------------------------------------------
435 Procedure upd
436   (p_effective_date               in date
437   ,p_rec                          in out nocopy per_ret_shd.g_rec_type
438   ) is
439 --
440   l_proc  varchar2(72) := g_package||'upd';
441 --
442 Begin
443   hr_utility.set_location('Entering:'||l_proc, 5);
444   --
445   -- We must lock the row which we need to update.
446   --
447   per_ret_shd.lck
448     (p_rec.cagr_retained_right_id
449     ,p_rec.object_version_number
450     );
451   --
452   -- 1. During an update system defaults are used to determine if
453   --    arguments have been defaulted or not. We must therefore
454   --    derive the full record structure values to be updated.
455   --
456   -- 2. Call the supporting update validate operations.
457   --
458   convert_defs(p_rec);
459   per_ret_bus.update_validate
460      (p_effective_date
461      ,p_rec
462      );
463   --
464   -- Call the supporting pre-update operation
465   --
466   per_ret_upd.pre_update(p_rec);
467   --
468   -- Update the row.
469   --
470   per_ret_upd.update_dml(p_rec);
471   --
472   -- Call the supporting post-update operation
473   --
474   per_ret_upd.post_update
475      (p_effective_date
476      ,p_rec
477      );
478 End upd;
479 --
480 -- ----------------------------------------------------------------------------
481 -- |---------------------------------< upd >----------------------------------|
482 -- ----------------------------------------------------------------------------
483 Procedure upd
484   (p_effective_date               in     date
485   ,p_cagr_retained_right_id      in     number
486   ,p_object_version_number        in out nocopy number
487   ,p_end_date                     in     date      default hr_api.g_date
488   ) is
489 --
490   l_rec   per_ret_shd.g_rec_type;
491   l_proc  varchar2(72) := g_package||'upd';
492 --
493 Begin
494   hr_utility.set_location('Entering:'||l_proc, 5);
495   --
496   -- Call conversion function to turn arguments into the
497   -- l_rec structure.
498   --
499   l_rec :=
500   per_ret_shd.convert_args
501   (p_cagr_retained_right_id
502   ,hr_api.g_number
503   ,hr_api.g_number
504   ,hr_api.g_number
505   ,hr_api.g_number
506   ,hr_api.g_varchar2
507   ,hr_api.g_number
508   ,hr_api.g_number
509   ,hr_api.g_number
510   ,hr_api.g_number
511   ,hr_api.g_number
512   ,hr_api.g_varchar2
513   ,hr_api.g_varchar2
514   ,hr_api.g_varchar2
515   ,hr_api.g_date
516   ,p_end_date
517   ,hr_api.g_number
518   ,hr_api.g_number
519   ,hr_api.g_number
520   ,hr_api.g_number
521   ,hr_api.g_number
522   ,hr_api.g_varchar2
523   ,hr_api.g_number
524   ,hr_api.g_number
525   ,p_object_version_number
526   ,hr_api.g_number
527   ,hr_api.g_number
528   ,hr_api.g_number
529   );
530   --
531   -- Having converted the arguments into the
532   -- plsql record structure we call the corresponding record
533   -- business process.
534   --
535   per_ret_upd.upd
536      (p_effective_date
537      ,l_rec
538      );
539   p_object_version_number := l_rec.object_version_number;
540   --
541   hr_utility.set_location(' Leaving:'||l_proc, 10);
542 End upd;
543 --
544 end per_ret_upd;