DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_VER_UPD

Source


1 Package Body pqh_ver_upd as
2 /* $Header: pqverrhi.pkb 115.3 2002/12/05 00:30:42 rpasapul noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pqh_ver_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 pqh_ver_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 pqh_de_wrkplc_vldtn_vers Row
69   --
70   update pqh_de_wrkplc_vldtn_vers
71     set
72      wrkplc_vldtn_ver_id             = p_rec.wrkplc_vldtn_ver_id
73     ,wrkplc_vldtn_id                 = p_rec.wrkplc_vldtn_id
74     ,version_number                  = p_rec.version_number
75     ,business_group_id               = p_rec.business_group_id
76     ,tariff_contract_code            = p_rec.tariff_contract_code
77     ,tariff_group_code               = p_rec.tariff_group_code
78     ,remuneration_job_description    = p_rec.remuneration_job_description
79     ,job_group_id                    = p_rec.job_group_id
80     ,remuneration_job_id             = p_rec.remuneration_job_id
81     ,derived_grade_id                = p_rec.derived_grade_id
82     ,derived_case_group_id           = p_rec.derived_case_group_id
83     ,derived_subcasgrp_id            = p_rec.derived_subcasgrp_id
84     ,user_enterable_grade_id         = p_rec.user_enterable_grade_id
85     ,user_enterable_case_group_id    = p_rec.user_enterable_case_group_id
86     ,user_enterable_subcasgrp_id     = p_rec.user_enterable_subcasgrp_id
87     ,freeze                          = p_rec.freeze
88     ,object_version_number           = p_rec.object_version_number
89     where wrkplc_vldtn_ver_id = p_rec.wrkplc_vldtn_ver_id;
90   --
91   --
92   --
93   hr_utility.set_location(' Leaving:'||l_proc, 10);
94 --
95 Exception
96   When hr_api.check_integrity_violated Then
97     -- A check constraint has been violated
98     --
99     pqh_ver_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     --
104     pqh_ver_shd.constraint_error
105       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
106   When hr_api.unique_integrity_violated Then
107     -- Unique integrity has been violated
108     --
109     pqh_ver_shd.constraint_error
110       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
111   When Others Then
112     --
113     Raise;
114 End update_dml;
115 --
116 -- ----------------------------------------------------------------------------
117 -- |------------------------------< pre_update >------------------------------|
118 -- ----------------------------------------------------------------------------
119 -- {Start Of Comments}
120 --
121 -- Description:
122 --   This private procedure contains any processing which is required before
123 --   the update dml.
124 --
125 -- Prerequisites:
126 --   This is an internal procedure which is called from the upd procedure.
127 --
128 -- In Parameters:
129 --   A Pl/Sql record structure.
130 --
131 -- Post Success:
132 --   Processing continues.
133 --
134 -- Post Failure:
135 --   If an error has occurred, an error message and exception wil be raised
136 --   but not handled.
137 --
138 -- Developer Implementation Notes:
139 --   Any pre-processing required before the update dml is issued should be
140 --   coded within this procedure. It is important to note that any 3rd party
141 --   maintenance should be reviewed before placing in this procedure.
142 --
143 -- Access Status:
144 --   Internal Row Handler Use Only.
145 --
146 -- {End Of Comments}
147 -- ----------------------------------------------------------------------------
148 Procedure pre_update
149   (p_rec in pqh_ver_shd.g_rec_type
150   ) 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
167 --   the 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 structure.
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
193   (p_effective_date               in date
194   ,p_rec                          in pqh_ver_shd.g_rec_type
195   ) is
196 --
197   l_proc  varchar2(72) := g_package||'post_update';
198 --
199 Begin
200   hr_utility.set_location('Entering:'||l_proc, 5);
201   begin
202     --
203     pqh_ver_rku.after_update
204       (p_effective_date              => p_effective_date
205       ,p_wrkplc_vldtn_ver_id
206       => p_rec.wrkplc_vldtn_ver_id
207       ,p_wrkplc_vldtn_id
208       => p_rec.wrkplc_vldtn_id
209       ,p_version_number
210       => p_rec.version_number
211       ,p_business_group_id
212       => p_rec.business_group_id
213       ,p_tariff_contract_code
214       => p_rec.tariff_contract_code
215       ,p_tariff_group_code
216       => p_rec.tariff_group_code
217       ,p_remuneration_job_description
218       => p_rec.remuneration_job_description
219       ,p_job_group_id
220       => p_rec.job_group_id
221       ,p_remuneration_job_id
222       => p_rec.remuneration_job_id
223       ,p_derived_grade_id
224       => p_rec.derived_grade_id
225       ,p_derived_case_group_id
226       => p_rec.derived_case_group_id
227       ,p_derived_subcasgrp_id
228       => p_rec.derived_subcasgrp_id
229       ,p_user_enterable_grade_id
230       => p_rec.user_enterable_grade_id
231       ,p_user_enterable_case_group_id
232       => p_rec.user_enterable_case_group_id
233       ,p_user_enterable_subcasgrp_id
234       => p_rec.user_enterable_subcasgrp_id
235       ,p_freeze
236       => p_rec.freeze
237       ,p_object_version_number
238       => p_rec.object_version_number
239       ,p_wrkplc_vldtn_id_o
240       => pqh_ver_shd.g_old_rec.wrkplc_vldtn_id
241       ,p_version_number_o
242       => pqh_ver_shd.g_old_rec.version_number
243       ,p_business_group_id_o
244       => pqh_ver_shd.g_old_rec.business_group_id
245       ,p_tariff_contract_code_o
246       => pqh_ver_shd.g_old_rec.tariff_contract_code
247       ,p_tariff_group_code_o
248       => pqh_ver_shd.g_old_rec.tariff_group_code
249       ,p_remuneration_job_descripti_o
250       => pqh_ver_shd.g_old_rec.remuneration_job_description
251       ,p_job_group_id_o
252       => pqh_ver_shd.g_old_rec.job_group_id
253       ,p_remuneration_job_id_o
254       => pqh_ver_shd.g_old_rec.remuneration_job_id
255       ,p_derived_grade_id_o
256       => pqh_ver_shd.g_old_rec.derived_grade_id
257       ,p_derived_case_group_id_o
258       => pqh_ver_shd.g_old_rec.derived_case_group_id
259       ,p_derived_subcasgrp_id_o
260       => pqh_ver_shd.g_old_rec.derived_subcasgrp_id
261       ,p_user_enterable_grade_id_o
262       => pqh_ver_shd.g_old_rec.user_enterable_grade_id
263       ,p_user_enterable_case_group__o
264       => pqh_ver_shd.g_old_rec.user_enterable_case_group_id
265       ,p_user_enterable_subcasgrp_i_o
266       => pqh_ver_shd.g_old_rec.user_enterable_subcasgrp_id
267       ,p_freeze_o
268       => pqh_ver_shd.g_old_rec.freeze
269       ,p_object_version_number_o
270       => pqh_ver_shd.g_old_rec.object_version_number
271       );
272     --
273   exception
274     --
275     when hr_api.cannot_find_prog_unit then
276       --
277       hr_api.cannot_find_prog_unit_error
278         (p_module_name => 'PQH_DE_WRKPLC_VLDTN_VERS'
279         ,p_hook_type   => 'AU');
280       --
281   end;
282   --
283   hr_utility.set_location(' Leaving:'||l_proc, 10);
284 End post_update;
285 --
286 -- ----------------------------------------------------------------------------
287 -- |-----------------------------< convert_defs >-----------------------------|
288 -- ----------------------------------------------------------------------------
289 -- {Start Of Comments}
290 --
291 -- Description:
292 --   The Convert_Defs procedure has one very important function:
293 --   It must return the record structure for the row with all system defaulted
294 --   values converted into its corresponding parameter value for update. When
295 --   we attempt to update a row through the Upd process , certain
296 --   parameters can be defaulted which enables flexibility in the calling of
297 --   the upd process (e.g. only attributes which need to be updated need to be
298 --   specified). For the upd process to determine which attributes
299 --   have NOT been specified we need to check if the parameter has a reserved
300 --   system default value. Therefore, for all parameters which have a
301 --   corresponding reserved system default mechanism specified we need to
302 --   check if a system default is being used. If a system default is being
303 --   used then we convert the defaulted value into its corresponding attribute
304 --   value held in the g_old_rec data structure.
305 --
306 -- Prerequisites:
307 --   This private function can only be called from the upd process.
308 --
309 -- In Parameters:
310 --   A Pl/Sql record structure.
311 --
312 -- Post Success:
313 --   The record structure will be returned with all system defaulted parameter
314 --   values converted into its current row attribute value.
315 --
316 -- Post Failure:
317 --   No direct error handling is required within this function. Any possible
318 --   errors within this procedure will be a PL/SQL value error due to
319 --   conversion of datatypes or data lengths.
320 --
321 -- Developer Implementation Notes:
322 --   None.
323 --
324 -- Access Status:
325 --   Internal Row Handler Use Only.
326 --
327 -- {End Of Comments}
328 -- ----------------------------------------------------------------------------
329 Procedure convert_defs
330   (p_rec in out nocopy pqh_ver_shd.g_rec_type
331   ) is
332 --
333 Begin
334   --
335   -- We must now examine each argument value in the
336   -- p_rec plsql record structure
337   -- to see if a system default is being used. If a system default
338   -- is being used then we must set to the 'current' argument value.
339   --
340   If (p_rec.wrkplc_vldtn_id = hr_api.g_number) then
341     p_rec.wrkplc_vldtn_id :=
342     pqh_ver_shd.g_old_rec.wrkplc_vldtn_id;
343   End If;
344   If (p_rec.version_number = hr_api.g_number) then
345     p_rec.version_number :=
346     pqh_ver_shd.g_old_rec.version_number;
347   End If;
348   If (p_rec.business_group_id = hr_api.g_number) then
349     p_rec.business_group_id :=
350     pqh_ver_shd.g_old_rec.business_group_id;
351   End If;
352   If (p_rec.tariff_contract_code = hr_api.g_varchar2) then
353     p_rec.tariff_contract_code :=
354     pqh_ver_shd.g_old_rec.tariff_contract_code;
355   End If;
356   If (p_rec.tariff_group_code = hr_api.g_varchar2) then
357     p_rec.tariff_group_code :=
358     pqh_ver_shd.g_old_rec.tariff_group_code;
359   End If;
360   If (p_rec.remuneration_job_description = hr_api.g_varchar2) then
361     p_rec.remuneration_job_description :=
362     pqh_ver_shd.g_old_rec.remuneration_job_description;
363   End If;
364   If (p_rec.job_group_id = hr_api.g_number) then
365     p_rec.job_group_id :=
366     pqh_ver_shd.g_old_rec.job_group_id;
367   End If;
368   If (p_rec.remuneration_job_id = hr_api.g_number) then
369     p_rec.remuneration_job_id :=
370     pqh_ver_shd.g_old_rec.remuneration_job_id;
371   End If;
372   If (p_rec.derived_grade_id = hr_api.g_number) then
373     p_rec.derived_grade_id :=
374     pqh_ver_shd.g_old_rec.derived_grade_id;
375   End If;
376   If (p_rec.derived_case_group_id = hr_api.g_number) then
377     p_rec.derived_case_group_id :=
378     pqh_ver_shd.g_old_rec.derived_case_group_id;
379   End If;
380   If (p_rec.derived_subcasgrp_id = hr_api.g_number) then
381     p_rec.derived_subcasgrp_id :=
382     pqh_ver_shd.g_old_rec.derived_subcasgrp_id;
383   End If;
384   If (p_rec.user_enterable_grade_id = hr_api.g_number) then
385     p_rec.user_enterable_grade_id :=
386     pqh_ver_shd.g_old_rec.user_enterable_grade_id;
387   End If;
388   If (p_rec.user_enterable_case_group_id = hr_api.g_number) then
389     p_rec.user_enterable_case_group_id :=
390     pqh_ver_shd.g_old_rec.user_enterable_case_group_id;
391   End If;
392   If (p_rec.user_enterable_subcasgrp_id = hr_api.g_number) then
393     p_rec.user_enterable_subcasgrp_id :=
394     pqh_ver_shd.g_old_rec.user_enterable_subcasgrp_id;
395   End If;
396   If (p_rec.freeze = hr_api.g_varchar2) then
397     p_rec.freeze :=
398     pqh_ver_shd.g_old_rec.freeze;
399   End If;
400   --
401 End convert_defs;
402 --
403 -- ----------------------------------------------------------------------------
404 -- |---------------------------------< upd >----------------------------------|
405 -- ----------------------------------------------------------------------------
406 Procedure upd
407   (p_effective_date               in date
408   ,p_rec                          in out nocopy pqh_ver_shd.g_rec_type
409   ) is
410 --
411   l_proc  varchar2(72) := g_package||'upd';
412 --
413 Begin
414   hr_utility.set_location('Entering:'||l_proc, 5);
415   --
416   -- We must lock the row which we need to update.
417   --
418   pqh_ver_shd.lck
419     (p_rec.wrkplc_vldtn_ver_id
420     ,p_rec.object_version_number
421     );
422   --
423   -- 1. During an update system defaults are used to determine if
424   --    arguments have been defaulted or not. We must therefore
425   --    derive the full record structure values to be updated.
426   --
427   -- 2. Call the supporting update validate operations.
428   --
429   convert_defs(p_rec);
430   pqh_ver_bus.update_validate
431      (p_effective_date
432      ,p_rec
433      );
434   --
435   -- Call to raise any errors on multi-message list
436   hr_multi_message.end_validation_set;
437   --
438   -- Call the supporting pre-update operation
439   --
440   pqh_ver_upd.pre_update(p_rec);
441   --
442   -- Update the row.
443   --
444   pqh_ver_upd.update_dml(p_rec);
445   --
446   -- Call the supporting post-update operation
447   --
448   pqh_ver_upd.post_update
449      (p_effective_date
450      ,p_rec
451      );
452   --
453   -- Call to raise any errors on multi-message list
454   hr_multi_message.end_validation_set;
455 End upd;
456 --
457 -- ----------------------------------------------------------------------------
458 -- |---------------------------------< upd >----------------------------------|
459 -- ----------------------------------------------------------------------------
460 Procedure upd
461   (p_effective_date               in     date
462   ,p_wrkplc_vldtn_ver_id          in     number
463   ,p_object_version_number        in out nocopy number
464   ,p_wrkplc_vldtn_id              in     number    default hr_api.g_number
465   ,p_version_number               in     number    default hr_api.g_number
466   ,p_business_group_id            in     number    default hr_api.g_number
467   ,p_tariff_contract_code         in     varchar2  default hr_api.g_varchar2
468   ,p_tariff_group_code            in     varchar2  default hr_api.g_varchar2
469   ,p_freeze                       in     varchar2  default hr_api.g_varchar2
470   ,p_remuneration_job_description in     varchar2  default hr_api.g_varchar2
471   ,p_job_group_id                 in     number    default hr_api.g_number
472   ,p_remuneration_job_id          in     number    default hr_api.g_number
473   ,p_derived_grade_id             in     number    default hr_api.g_number
474   ,p_derived_case_group_id        in     number    default hr_api.g_number
475   ,p_derived_subcasgrp_id         in     number    default hr_api.g_number
476   ,p_user_enterable_grade_id      in     number    default hr_api.g_number
477   ,p_user_enterable_case_group_id in     number    default hr_api.g_number
478   ,p_user_enterable_subcasgrp_id  in     number    default hr_api.g_number
479   ) is
480 --
481   l_rec   pqh_ver_shd.g_rec_type;
482   l_proc  varchar2(72) := g_package||'upd';
483 --
484 Begin
485   hr_utility.set_location('Entering:'||l_proc, 5);
486   --
487   -- Call conversion function to turn arguments into the
488   -- l_rec structure.
489   --
490   l_rec :=
491   pqh_ver_shd.convert_args
492   (p_wrkplc_vldtn_ver_id
493   ,p_wrkplc_vldtn_id
494   ,p_version_number
495   ,p_business_group_id
496   ,p_tariff_contract_code
497   ,p_tariff_group_code
498   ,p_remuneration_job_description
499   ,p_job_group_id
500   ,p_remuneration_job_id
501   ,p_derived_grade_id
502   ,p_derived_case_group_id
503   ,p_derived_subcasgrp_id
504   ,p_user_enterable_grade_id
505   ,p_user_enterable_case_group_id
506   ,p_user_enterable_subcasgrp_id
507   ,p_freeze
508   ,p_object_version_number
509   );
510   --
511   -- Having converted the arguments into the
512   -- plsql record structure we call the corresponding record
513   -- business process.
514   --
515   pqh_ver_upd.upd
516      (p_effective_date
517      ,l_rec
518      );
519   p_object_version_number := l_rec.object_version_number;
520   --
521   hr_utility.set_location(' Leaving:'||l_proc, 10);
522 End upd;
523 --
524 end pqh_ver_upd;