DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_RMN_UPD

Source


1 Package Body pqh_rmn_upd as
2 /* $Header: pqrmnrhi.pkb 120.0 2005/05/29 02:33 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pqh_rmn_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_rmn_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_rate_matrix_nodes Row
69   --
70   update pqh_rate_matrix_nodes
71     set
72      rate_matrix_node_id             = p_rec.rate_matrix_node_id
73     ,short_code                      = p_rec.short_code
74     ,pl_id                           = p_rec.pl_id
75     ,level_number                    = p_rec.level_number
76     ,criteria_short_code             = p_rec.criteria_short_code
77     ,node_name                       = p_rec.node_name
78     ,parent_node_id                  = p_rec.parent_node_id
79     ,eligy_prfl_id                   = p_rec.eligy_prfl_id
80     ,business_group_id               = p_rec.business_group_id
81     ,legislation_code                = p_rec.legislation_code
82     ,object_version_number           = p_rec.object_version_number
83     where rate_matrix_node_id = p_rec.rate_matrix_node_id;
84   --
85   --
86   --
87   hr_utility.set_location(' Leaving:'||l_proc, 10);
88 --
89 Exception
90   When hr_api.check_integrity_violated Then
91     -- A check constraint has been violated
92     --
93     pqh_rmn_shd.constraint_error
94       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
95   When hr_api.parent_integrity_violated Then
96     -- Parent integrity has been violated
97     --
98     pqh_rmn_shd.constraint_error
99       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
100   When hr_api.unique_integrity_violated Then
101     -- Unique integrity has been violated
102     --
103     pqh_rmn_shd.constraint_error
104       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
105   When Others Then
106     --
107     Raise;
108 End update_dml;
109 --
110 -- ----------------------------------------------------------------------------
111 -- |------------------------------< pre_update >------------------------------|
112 -- ----------------------------------------------------------------------------
113 -- {Start Of Comments}
114 --
115 -- Description:
116 --   This private procedure contains any processing which is required before
117 --   the update dml.
118 --
119 -- Prerequisites:
120 --   This is an internal procedure which is called from the upd procedure.
121 --
122 -- In Parameters:
123 --   A Pl/Sql record structure.
124 --
125 -- Post Success:
126 --   Processing continues.
127 --
128 -- Post Failure:
129 --   If an error has occurred, an error message and exception wil be raised
130 --   but not handled.
131 --
132 -- Developer Implementation Notes:
133 --   Any pre-processing required before the update dml is issued should be
134 --   coded within this procedure. It is important to note that any 3rd party
135 --   maintenance should be reviewed before placing in this procedure.
136 --
137 -- Access Status:
138 --   Internal Row Handler Use Only.
139 --
140 -- {End Of Comments}
141 -- ----------------------------------------------------------------------------
142 Procedure pre_update
143   (p_rec in pqh_rmn_shd.g_rec_type
144   ) is
145 --
146   l_proc  varchar2(72) := g_package||'pre_update';
147 --
148 Begin
149   hr_utility.set_location('Entering:'||l_proc, 5);
150   --
151   hr_utility.set_location(' Leaving:'||l_proc, 10);
152 End pre_update;
153 --
154 -- ----------------------------------------------------------------------------
155 -- |-----------------------------< post_update >------------------------------|
156 -- ----------------------------------------------------------------------------
157 -- {Start Of Comments}
158 --
159 -- Description:
160 --   This private procedure contains any processing which is required after
161 --   the update dml.
162 --
163 -- Prerequisites:
164 --   This is an internal procedure which is called from the upd procedure.
165 --
166 -- In Parameters:
167 --   A Pl/Sql record structure.
168 --
169 -- Post Success:
170 --   Processing continues.
171 --
172 -- Post Failure:
173 --   If an error has occurred, an error message and exception will be raised
174 --   but not handled.
175 --
176 -- Developer Implementation Notes:
177 --   Any post-processing required after the update dml is issued should be
178 --   coded within this procedure. It is important to note that any 3rd party
179 --   maintenance should be reviewed before placing in this procedure.
180 --
181 -- Access Status:
182 --   Internal Row Handler Use Only.
183 --
184 -- {End Of Comments}
185 -- ----------------------------------------------------------------------------
186 Procedure post_update
187   (p_rec                          in pqh_rmn_shd.g_rec_type
188   ) is
189 --
190   l_proc  varchar2(72) := g_package||'post_update';
191 --
192 Begin
193   hr_utility.set_location('Entering:'||l_proc, 5);
194   begin
195     --
196     pqh_rmn_rku.after_update
197       (p_rate_matrix_node_id
198       => p_rec.rate_matrix_node_id
199       ,p_short_code
200       => p_rec.short_code
201       ,p_pl_id
202       => p_rec.pl_id
203       ,p_level_number
204       => p_rec.level_number
205       ,p_criteria_short_code
206       => p_rec.criteria_short_code
207       ,p_node_name
208       => p_rec.node_name
209       ,p_parent_node_id
210       => p_rec.parent_node_id
211       ,p_eligy_prfl_id
212       => p_rec.eligy_prfl_id
213       ,p_business_group_id
214       => p_rec.business_group_id
215       ,p_legislation_code
216       => p_rec.legislation_code
217       ,p_object_version_number
218       => p_rec.object_version_number
219       ,p_short_code_o
220       => pqh_rmn_shd.g_old_rec.short_code
221       ,p_pl_id_o
222       => pqh_rmn_shd.g_old_rec.pl_id
223       ,p_level_number_o
224       => pqh_rmn_shd.g_old_rec.level_number
225       ,p_criteria_short_code_o
226       => pqh_rmn_shd.g_old_rec.criteria_short_code
227       ,p_node_name_o
228       => pqh_rmn_shd.g_old_rec.node_name
229       ,p_parent_node_id_o
230       => pqh_rmn_shd.g_old_rec.parent_node_id
231       ,p_eligy_prfl_id_o
232       => pqh_rmn_shd.g_old_rec.eligy_prfl_id
233       ,p_business_group_id_o
234       => pqh_rmn_shd.g_old_rec.business_group_id
235       ,p_legislation_code_o
236       => pqh_rmn_shd.g_old_rec.legislation_code
237       ,p_object_version_number_o
238       => pqh_rmn_shd.g_old_rec.object_version_number
239       );
240     --
241   exception
242     --
243     when hr_api.cannot_find_prog_unit then
244       --
245       hr_api.cannot_find_prog_unit_error
246         (p_module_name => 'PQH_RATE_MATRIX_NODES'
247         ,p_hook_type   => 'AU');
248       --
249   end;
250   --
251   hr_utility.set_location(' Leaving:'||l_proc, 10);
252 End post_update;
253 --
254 -- ----------------------------------------------------------------------------
255 -- |-----------------------------< convert_defs >-----------------------------|
256 -- ----------------------------------------------------------------------------
257 -- {Start Of Comments}
258 --
259 -- Description:
260 --   The Convert_Defs procedure has one very important function:
261 --   It must return the record structure for the row with all system defaulted
262 --   values converted into its corresponding parameter value for update. When
263 --   we attempt to update a row through the Upd process , certain
264 --   parameters can be defaulted which enables flexibility in the calling of
265 --   the upd process (e.g. only attributes which need to be updated need to be
266 --   specified). For the upd process to determine which attributes
267 --   have NOT been specified we need to check if the parameter has a reserved
268 --   system default value. Therefore, for all parameters which have a
269 --   corresponding reserved system default mechanism specified we need to
270 --   check if a system default is being used. If a system default is being
271 --   used then we convert the defaulted value into its corresponding attribute
272 --   value held in the g_old_rec data structure.
273 --
274 -- Prerequisites:
275 --   This private function can only be called from the upd process.
276 --
277 -- In Parameters:
278 --   A Pl/Sql record structure.
279 --
280 -- Post Success:
281 --   The record structure will be returned with all system defaulted parameter
282 --   values converted into its current row attribute value.
283 --
284 -- Post Failure:
285 --   No direct error handling is required within this function. Any possible
286 --   errors within this procedure will be a PL/SQL value error due to
287 --   conversion of datatypes or data lengths.
288 --
289 -- Developer Implementation Notes:
290 --   None.
291 --
292 -- Access Status:
293 --   Internal Row Handler Use Only.
294 --
295 -- {End Of Comments}
296 -- ----------------------------------------------------------------------------
297 Procedure convert_defs
298   (p_rec in out nocopy pqh_rmn_shd.g_rec_type
299   ) is
300 --
301 Begin
302   --
303   -- We must now examine each argument value in the
304   -- p_rec plsql record structure
305   -- to see if a system default is being used. If a system default
306   -- is being used then we must set to the 'current' argument value.
307   --
308   If (p_rec.short_code = hr_api.g_varchar2) then
309     p_rec.short_code :=
310     pqh_rmn_shd.g_old_rec.short_code;
311   End If;
312   If (p_rec.pl_id = hr_api.g_number) then
313     p_rec.pl_id :=
314     pqh_rmn_shd.g_old_rec.pl_id;
315   End If;
316   If (p_rec.level_number = hr_api.g_number) then
317     p_rec.level_number :=
318     pqh_rmn_shd.g_old_rec.level_number;
319   End If;
320   If (p_rec.criteria_short_code = hr_api.g_varchar2) then
321     p_rec.criteria_short_code :=
322     pqh_rmn_shd.g_old_rec.criteria_short_code;
323   End If;
324   If (p_rec.node_name = hr_api.g_varchar2) then
325     p_rec.node_name :=
326     pqh_rmn_shd.g_old_rec.node_name;
327   End If;
328   If (p_rec.parent_node_id = hr_api.g_number) then
329     p_rec.parent_node_id :=
330     pqh_rmn_shd.g_old_rec.parent_node_id;
331   End If;
332   If (p_rec.eligy_prfl_id = hr_api.g_number) then
333     p_rec.eligy_prfl_id :=
334     pqh_rmn_shd.g_old_rec.eligy_prfl_id;
335   End If;
336   If (p_rec.business_group_id = hr_api.g_number) then
337     p_rec.business_group_id :=
338     pqh_rmn_shd.g_old_rec.business_group_id;
339   End If;
340   If (p_rec.legislation_code = hr_api.g_varchar2) then
341     p_rec.legislation_code :=
342     pqh_rmn_shd.g_old_rec.legislation_code;
343   End If;
344   --
345 End convert_defs;
346 --
347 -- ----------------------------------------------------------------------------
348 -- |---------------------------------< upd >----------------------------------|
349 -- ----------------------------------------------------------------------------
350 Procedure upd
351   (p_rec                          in out nocopy pqh_rmn_shd.g_rec_type
352   ) is
353 --
354   l_proc  varchar2(72) := g_package||'upd';
355 --
356 Begin
357   hr_utility.set_location('Entering:'||l_proc, 5);
358   --
359   -- We must lock the row which we need to update.
360   --
361   pqh_rmn_shd.lck
362     (p_rec.rate_matrix_node_id
363     ,p_rec.object_version_number
364     );
365   --
366   -- 1. During an update system defaults are used to determine if
367   --    arguments have been defaulted or not. We must therefore
368   --    derive the full record structure values to be updated.
369   --
370   -- 2. Call the supporting update validate operations.
371   --
372   convert_defs(p_rec);
373   pqh_rmn_bus.update_validate
374      (p_rec
375      );
376   --
377   -- Call to raise any errors on multi-message list
378   hr_multi_message.end_validation_set;
379   --
380   -- Call the supporting pre-update operation
381   --
382   pqh_rmn_upd.pre_update(p_rec);
383   --
384   -- Update the row.
385   --
386   pqh_rmn_upd.update_dml(p_rec);
387   --
388   -- Call the supporting post-update operation
389   --
390   pqh_rmn_upd.post_update
391      (p_rec
392      );
393   --
394   -- Call to raise any errors on multi-message list
395   hr_multi_message.end_validation_set;
396 End upd;
397 --
398 -- ----------------------------------------------------------------------------
399 -- |---------------------------------< upd >----------------------------------|
400 -- ----------------------------------------------------------------------------
401 Procedure upd
402   (p_rate_matrix_node_id          in     number
403   ,p_object_version_number        in out nocopy number
404   ,p_short_code                   in     varchar2  default hr_api.g_varchar2
405   ,p_level_number                 in     number    default hr_api.g_number
406   ,p_criteria_short_code          in     varchar2  default hr_api.g_varchar2
407   ,p_node_name                    in     varchar2  default hr_api.g_varchar2
408   ,p_pl_id                        in     number    default hr_api.g_number
409   ,p_parent_node_id               in     number    default hr_api.g_number
410   ,p_eligy_prfl_id                in     number    default hr_api.g_number
411   ,p_business_group_id            in     number    default hr_api.g_number
412   ,p_legislation_code             in     varchar2  default hr_api.g_varchar2
413   ) is
414 --
415   l_rec   pqh_rmn_shd.g_rec_type;
416   l_proc  varchar2(72) := g_package||'upd';
417 --
418 Begin
419   hr_utility.set_location('Entering:'||l_proc, 5);
420   --
421   -- Call conversion function to turn arguments into the
422   -- l_rec structure.
423   --
424   l_rec :=
425   pqh_rmn_shd.convert_args
426   (p_rate_matrix_node_id
427   ,p_short_code
428   ,p_pl_id
429   ,p_level_number
430   ,p_criteria_short_code
431   ,p_node_name
432   ,p_parent_node_id
433   ,p_eligy_prfl_id
434   ,p_business_group_id
435   ,p_legislation_code
436   ,p_object_version_number
437   );
438   --
439   -- Having converted the arguments into the
440   -- plsql record structure we call the corresponding record
441   -- business process.
442   --
443   pqh_rmn_upd.upd
444      (l_rec
445      );
446   p_object_version_number := l_rec.object_version_number;
447   --
448   hr_utility.set_location(' Leaving:'||l_proc, 10);
449 End upd;
450 --
451 end pqh_rmn_upd;