DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_PSS_UPD

Source


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