DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_SSM_UPD

Source


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