DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_RNK_UPD

Source


1 Package Body pqh_rnk_upd as
2 /* $Header: pqrnkrhi.pkb 120.1 2005/06/23 13:27 nsanghal noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package constant varchar2(33) := '  pqh_rnk_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_rnk_shd.g_rec_type
56   ) is
57 --
58   l_proc constant  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_rank_processes Row
69   --
70   update pqh_rank_processes
71     set
72      rank_process_id                 = p_rec.rank_process_id
73     ,pgm_id                          = p_rec.pgm_id
74     ,pl_id                           = p_rec.pl_id
75     ,oipl_id                         = p_rec.oipl_id
76     ,process_cd                      = p_rec.process_cd
77     ,process_date                    = p_rec.process_date
78     ,benefit_action_id               = p_rec.benefit_action_id
79     ,person_id                       = p_rec.person_id
80     ,assignment_id                   = p_rec.assignment_id
81     ,total_score                     = p_rec.total_score
82     ,object_version_number           = p_rec.object_version_number
83     ,request_id                      = p_rec.request_id
84     ,business_group_id               = p_rec.business_group_id
85     ,per_in_ler_id                   = p_rec.per_in_ler_id
86     where rank_process_id = p_rec.rank_process_id;
87   --
88   --
89   --
90   hr_utility.set_location(' Leaving:'||l_proc, 10);
91 --
92 Exception
93   When hr_api.check_integrity_violated Then
94     -- A check constraint has been violated
95     --
96     pqh_rnk_shd.constraint_error
97       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
98   When hr_api.parent_integrity_violated Then
99     -- Parent integrity has been violated
100     --
101     pqh_rnk_shd.constraint_error
102       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
103   When hr_api.unique_integrity_violated Then
104     -- Unique integrity has been violated
105     --
106     pqh_rnk_shd.constraint_error
107       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
108   When Others Then
109     --
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 structure.
127 --
128 -- Post Success:
129 --   Processing continues.
130 --
131 -- Post Failure:
132 --   If an error has occurred, an error message and exception wil 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
146   (p_rec in pqh_rnk_shd.g_rec_type
147   ) is
148 --
149   l_proc constant  varchar2(72) := g_package||'pre_update';
150 --
151 Begin
152   hr_utility.set_location('Entering:'||l_proc, 5);
153   --
154   hr_utility.set_location(' Leaving:'||l_proc, 10);
155 End pre_update;
156 --
157 -- ----------------------------------------------------------------------------
158 -- |-----------------------------< post_update >------------------------------|
159 -- ----------------------------------------------------------------------------
160 -- {Start Of Comments}
161 --
162 -- Description:
163 --   This private procedure contains any processing which is required after
164 --   the update dml.
165 --
166 -- Prerequisites:
167 --   This is an internal procedure which is called from the upd procedure.
168 --
169 -- In Parameters:
170 --   A Pl/Sql record structure.
171 --
172 -- Post Success:
173 --   Processing continues.
174 --
175 -- Post Failure:
176 --   If an error has occurred, an error message and exception will be raised
177 --   but not handled.
178 --
179 -- Developer Implementation Notes:
180 --   Any post-processing required after the update dml is issued should be
181 --   coded within this procedure. It is important to note that any 3rd party
182 --   maintenance should be reviewed before placing in this procedure.
183 --
184 -- Access Status:
185 --   Internal Row Handler Use Only.
186 --
187 -- {End Of Comments}
188 -- ----------------------------------------------------------------------------
189 Procedure post_update
190   (p_effective_date               in date
191   ,p_rec                          in pqh_rnk_shd.g_rec_type
192   ) is
193 --
194   l_proc constant  varchar2(72) := g_package||'post_update';
195 --
196 Begin
197   hr_utility.set_location('Entering:'||l_proc, 5);
198   begin
199     --
200     pqh_rnk_rku.after_update
201       (p_effective_date
202       => p_effective_date
203       ,p_rank_process_id
204       => p_rec.rank_process_id
205       ,p_pgm_id
206       => p_rec.pgm_id
207       ,p_pl_id
208       => p_rec.pl_id
209       ,p_oipl_id
210       => p_rec.oipl_id
211       ,p_process_cd
212       => p_rec.process_cd
213       ,p_process_date
214       => p_rec.process_date
215       ,p_benefit_action_id
216       => p_rec.benefit_action_id
217       ,p_person_id
218       => p_rec.person_id
219       ,p_assignment_id
220       => p_rec.assignment_id
221       ,p_total_score
222       => p_rec.total_score
223       ,p_object_version_number
224       => p_rec.object_version_number
225       ,p_request_id
226       => p_rec.request_id
227       ,p_business_group_id
228       => p_rec.business_group_id
229       ,p_per_in_ler_id
230       => p_rec.per_in_ler_id
231       ,p_pgm_id_o
232       => pqh_rnk_shd.g_old_rec.pgm_id
233       ,p_pl_id_o
234       => pqh_rnk_shd.g_old_rec.pl_id
235       ,p_oipl_id_o
236       => pqh_rnk_shd.g_old_rec.oipl_id
237       ,p_process_cd_o
238       => pqh_rnk_shd.g_old_rec.process_cd
239       ,p_process_date_o
240       => pqh_rnk_shd.g_old_rec.process_date
241       ,p_benefit_action_id_o
242       => pqh_rnk_shd.g_old_rec.benefit_action_id
243       ,p_person_id_o
244       => pqh_rnk_shd.g_old_rec.person_id
245       ,p_assignment_id_o
246       => pqh_rnk_shd.g_old_rec.assignment_id
247       ,p_total_score_o
248       => pqh_rnk_shd.g_old_rec.total_score
249       ,p_object_version_number_o
250       => pqh_rnk_shd.g_old_rec.object_version_number
251       ,p_request_id_o
252       => pqh_rnk_shd.g_old_rec.request_id
253       ,p_business_group_id_o
254       => pqh_rnk_shd.g_old_rec.business_group_id
255       ,p_per_in_ler_id_o
256       => pqh_rnk_shd.g_old_rec.per_in_ler_id
257       );
258     --
259   exception
260     --
261     when hr_api.cannot_find_prog_unit then
262       --
263       hr_api.cannot_find_prog_unit_error
264         (p_module_name => 'PQH_RANK_PROCESSES'
265         ,p_hook_type   => 'AU');
266       --
267   end;
268   --
269   hr_utility.set_location(' Leaving:'||l_proc, 10);
270 End post_update;
271 --
272 -- ----------------------------------------------------------------------------
273 -- |-----------------------------< convert_defs >-----------------------------|
274 -- ----------------------------------------------------------------------------
275 -- {Start Of Comments}
276 --
277 -- Description:
278 --   The Convert_Defs procedure has one very important function:
279 --   It must return the record structure for the row with all system defaulted
280 --   values converted into its corresponding parameter value for update. When
281 --   we attempt to update a row through the Upd process , certain
282 --   parameters can be defaulted which enables flexibility in the calling of
283 --   the upd process (e.g. only attributes which need to be updated need to be
284 --   specified). For the upd process to determine which attributes
285 --   have NOT been specified we need to check if the parameter has a reserved
286 --   system default value. Therefore, for all parameters which have a
287 --   corresponding reserved system default mechanism specified we need to
288 --   check if a system default is being used. If a system default is being
289 --   used then we convert the defaulted value into its corresponding attribute
290 --   value held in the g_old_rec data structure.
291 --
292 -- Prerequisites:
293 --   This private function can only be called from the upd process.
294 --
295 -- In Parameters:
296 --   A Pl/Sql record structure.
297 --
298 -- Post Success:
299 --   The record structure will be returned with all system defaulted parameter
300 --   values converted into its current row attribute value.
301 --
302 -- Post Failure:
303 --   No direct error handling is required within this function. Any possible
304 --   errors within this procedure will be a PL/SQL value error due to
305 --   conversion of datatypes or data lengths.
306 --
307 -- Developer Implementation Notes:
308 --   None.
309 --
310 -- Access Status:
311 --   Internal Row Handler Use Only.
312 --
313 -- {End Of Comments}
314 -- ----------------------------------------------------------------------------
315 Procedure convert_defs
316   (p_rec in out nocopy pqh_rnk_shd.g_rec_type
317   ) is
318 --
319 Begin
320   --
321   -- We must now examine each argument value in the
322   -- p_rec plsql record structure
323   -- to see if a system default is being used. If a system default
324   -- is being used then we must set to the 'current' argument value.
325   --
326   If (p_rec.pgm_id = hr_api.g_number) then
327     p_rec.pgm_id :=
328     pqh_rnk_shd.g_old_rec.pgm_id;
329   End If;
330   If (p_rec.pl_id = hr_api.g_number) then
331     p_rec.pl_id :=
332     pqh_rnk_shd.g_old_rec.pl_id;
333   End If;
334   If (p_rec.oipl_id = hr_api.g_number) then
335     p_rec.oipl_id :=
336     pqh_rnk_shd.g_old_rec.oipl_id;
337   End If;
338   If (p_rec.process_cd = hr_api.g_varchar2) then
339     p_rec.process_cd :=
340     pqh_rnk_shd.g_old_rec.process_cd;
341   End If;
342   If (p_rec.process_date = hr_api.g_date) then
343     p_rec.process_date :=
344     pqh_rnk_shd.g_old_rec.process_date;
345   End If;
346   If (p_rec.benefit_action_id = hr_api.g_number) then
347     p_rec.benefit_action_id :=
348     pqh_rnk_shd.g_old_rec.benefit_action_id;
349   End If;
350   If (p_rec.person_id = hr_api.g_number) then
351     p_rec.person_id :=
352     pqh_rnk_shd.g_old_rec.person_id;
353   End If;
354   If (p_rec.assignment_id = hr_api.g_number) then
355     p_rec.assignment_id :=
356     pqh_rnk_shd.g_old_rec.assignment_id;
357   End If;
358   If (p_rec.total_score = hr_api.g_number) then
359     p_rec.total_score :=
360     pqh_rnk_shd.g_old_rec.total_score;
361   End If;
362   If (p_rec.request_id = hr_api.g_number) then
363     p_rec.request_id :=
364     pqh_rnk_shd.g_old_rec.request_id;
365   End If;
366   If (p_rec.business_group_id = hr_api.g_number) then
367     p_rec.business_group_id :=
368     pqh_rnk_shd.g_old_rec.business_group_id;
369   End If;
370   If (p_rec.per_in_ler_id = hr_api.g_number) then
371     p_rec.per_in_ler_id :=
372     pqh_rnk_shd.g_old_rec.per_in_ler_id;
373   End If;
374   --
375 End convert_defs;
376 --
377 -- ----------------------------------------------------------------------------
378 -- |---------------------------------< upd >----------------------------------|
379 -- ----------------------------------------------------------------------------
380 Procedure upd
381   (p_effective_date               in date
382   ,p_rec                          in out nocopy pqh_rnk_shd.g_rec_type
383   ) is
384 --
385   l_proc constant  varchar2(72) := g_package||'upd';
386 --
387 Begin
388   hr_utility.set_location('Entering:'||l_proc, 5);
389   --
390   -- We must lock the row which we need to update.
391   --
392   pqh_rnk_shd.lck
393     (p_rec.rank_process_id
394     ,p_rec.object_version_number
395     );
396   --
397   -- 1. During an update system defaults are used to determine if
398   --    arguments have been defaulted or not. We must therefore
399   --    derive the full record structure values to be updated.
400   --
401   -- 2. Call the supporting update validate operations.
402   --
403   convert_defs(p_rec);
404   pqh_rnk_bus.update_validate
405      (p_effective_date
406      ,p_rec
407      );
408   --
409   -- Call to raise any errors on multi-message list
410   hr_multi_message.end_validation_set;
411   --
412   -- Call the supporting pre-update operation
413   --
414   pqh_rnk_upd.pre_update(p_rec);
415   --
416   -- Update the row.
417   --
418   pqh_rnk_upd.update_dml(p_rec);
419   --
420   -- Call the supporting post-update operation
421   --
422   pqh_rnk_upd.post_update
423      (p_effective_date
424      ,p_rec
425      );
426   --
427   -- Call to raise any errors on multi-message list
428   hr_multi_message.end_validation_set;
429 End upd;
430 --
431 -- ----------------------------------------------------------------------------
432 -- |---------------------------------< upd >----------------------------------|
433 -- ----------------------------------------------------------------------------
434 Procedure upd
435   (p_effective_date               in     date
436   ,p_rank_process_id              in     number
437   ,p_object_version_number        in out nocopy number
438   ,p_process_date                 in     date      default hr_api.g_date
439   ,p_pgm_id                       in     number    default hr_api.g_number
440   ,p_pl_id                        in     number    default hr_api.g_number
441   ,p_oipl_id                      in     number    default hr_api.g_number
442   ,p_process_cd                   in     varchar2  default hr_api.g_varchar2
443   ,p_benefit_action_id            in     number    default hr_api.g_number
444   ,p_person_id                    in     number    default hr_api.g_number
445   ,p_assignment_id                in     number    default hr_api.g_number
446   ,p_total_score                  in     number    default hr_api.g_number
447   ,p_request_id                   in     number    default hr_api.g_number
448   ,p_business_group_id            in     number    default hr_api.g_number
449   ,p_per_in_ler_id                in     number    default hr_api.g_number
450   ) is
451 --
452   l_rec   pqh_rnk_shd.g_rec_type;
453   l_proc constant  varchar2(72) := g_package||'upd';
454 --
455 Begin
456   hr_utility.set_location('Entering:'||l_proc, 5);
457   --
458   -- Call conversion function to turn arguments into the
459   -- l_rec structure.
460   --
461   l_rec :=
462   pqh_rnk_shd.convert_args
463   (p_rank_process_id
464   ,p_pgm_id
465   ,p_pl_id
466   ,p_oipl_id
467   ,p_process_cd
468   ,p_process_date
469   ,p_benefit_action_id
470   ,p_person_id
471   ,p_assignment_id
472   ,p_total_score
473   ,p_object_version_number
474   ,p_request_id
475   ,p_business_group_id
476   ,p_per_in_ler_id
477   );
478   --
479   -- Having converted the arguments into the
480   -- plsql record structure we call the corresponding record
481   -- business process.
482   --
483   pqh_rnk_upd.upd
484      (p_effective_date
485      ,l_rec
486      );
487   p_object_version_number := l_rec.object_version_number;
488   --
489   hr_utility.set_location(' Leaving:'||l_proc, 10);
490 End upd;
491 --
492 end pqh_rnk_upd;