DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_HRR_UPD

Source


1 Package Body hxc_hrr_upd as
2 /* $Header: hxchrrrhi.pkb 120.3 2005/09/23 10:43:47 sechandr noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  hxc_hrr_upd.';  -- Global package name
9 g_debug boolean		:=hr_utility.debug_enabled;
10 --
11 -- ----------------------------------------------------------------------------
12 -- |------------------------------< update_dml >------------------------------|
13 -- ----------------------------------------------------------------------------
14 -- {Start Of Comments}
15 --
16 -- Description:
17 --   This procedure controls the actual dml update logic. The processing of
18 --   this procedure is:
19 --   1) Increment the object_version_number by 1 if the object_version_number
20 --      is defined as an attribute for this entity.
21 --   2) To set and unset the g_api_dml status as required (as we are about to
22 --      perform dml).
23 --   3) To update the specified row in the schema using the primary key in
24 --      the predicates.
25 --   4) To trap any constraint violations that may have occurred.
26 --   5) To raise any other errors.
27 --
28 -- Prerequisites:
29 --   This is an internal private procedure which must be called from the upd
30 --   procedure.
31 --
32 -- In Parameters:
33 --   A Pl/Sql record structre.
34 --
35 -- Post Success:
36 --   The specified row will be updated in the schema.
37 --
38 -- Post Failure:
39 --   On the update dml failure it is important to note that we always reset the
40 --   g_api_dml status to false.
41 --   If a check, unique or parent integrity constraint violation is raised the
42 --   constraint_error procedure will be called.
43 --   If any other error is reported, the error will be raised after the
44 --   g_api_dml status is reset.
45 --
46 -- Developer Implementation Notes:
47 --   The update 'set' attribute list should be modified if any of your
48 --   attributes are not updateable.
49 --
50 -- Access Status:
51 --   Internal Row Handler Use Only.
52 --
53 -- {End Of Comments}
54 -- ----------------------------------------------------------------------------
55 Procedure update_dml
56   (p_rec in out nocopy hxc_hrr_shd.g_rec_type
57   ) is
58 --
59   l_proc  varchar2(72);
60 --
61 Begin
62   if g_debug then
63 	l_proc := g_package||'update_dml';
64 	hr_utility.set_location('Entering:'||l_proc, 5);
65   end if;
66   --
67   -- Increment the object version
68   p_rec.object_version_number := p_rec.object_version_number + 1;
69   --
70   --
71   --
72   -- Update the hxc_resource_rules Row
73   --
74   update hxc_resource_rules
75     set
76      resource_rule_id                = p_rec.resource_rule_id
77     ,name                            = p_rec.name
78     ,business_group_id		     = p_rec.business_group_id
79     ,legislation_code		     = p_rec.legislation_code
80     ,eligibility_criteria_type       = p_rec.eligibility_criteria_type
81     ,eligibility_criteria_id         = p_rec.eligibility_criteria_id
82     ,pref_hierarchy_id               = p_rec.pref_hierarchy_id
83     ,rule_evaluation_order           = p_rec.rule_evaluation_order
84     ,resource_type                   = p_rec.resource_type
85     ,start_date                      = p_rec.start_date
86     ,end_date                        = p_rec.end_date
87     ,object_version_number           = p_rec.object_version_number
88         ,last_updated_by		     = fnd_global.user_id
89     ,last_update_date		     = sysdate
90     ,last_update_login	             = fnd_global.login_id
91 
92     where resource_rule_id = p_rec.resource_rule_id;
93   --
94   --
95   --
96   if g_debug then
97 	hr_utility.set_location(' Leaving:'||l_proc, 10);
98   end if;
99 --
100 Exception
101   When hr_api.check_integrity_violated Then
102     -- A check constraint has been violated
103     --
104     hxc_hrr_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     --
109     hxc_hrr_shd.constraint_error
110       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
111   When hr_api.unique_integrity_violated Then
112     -- Unique integrity has been violated
113     --
114     hxc_hrr_shd.constraint_error
115       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
116   When Others Then
117     --
118     Raise;
119 End update_dml;
120 --
121 -- ----------------------------------------------------------------------------
122 -- |------------------------------< pre_update >------------------------------|
123 -- ----------------------------------------------------------------------------
124 -- {Start Of Comments}
125 --
126 -- Description:
127 --   This private procedure contains any processing which is required before
128 --   the update dml.
129 --
130 -- Prerequisites:
131 --   This is an internal procedure which is called from the upd procedure.
132 --
133 -- In Parameters:
134 --   A Pl/Sql record structure.
135 --
136 -- Post Success:
137 --   Processing continues.
138 --
139 -- Post Failure:
140 --   If an error has occurred, an error message and exception wil be raised
141 --   but not handled.
142 --
143 -- Developer Implementation Notes:
144 --   Any pre-processing required before the update dml is issued should be
145 --   coded within this procedure. It is important to note that any 3rd party
146 --   maintenance should be reviewed before placing in this procedure.
147 --
148 -- Access Status:
149 --   Internal Row Handler Use Only.
150 --
151 -- {End Of Comments}
152 -- ----------------------------------------------------------------------------
153 Procedure pre_update
154   (p_rec in hxc_hrr_shd.g_rec_type
155   ) is
156 --
157   l_proc  varchar2(72);
158 --
159 Begin
160   if g_debug then
161 	  l_proc := g_package||'pre_update';
162 	  hr_utility.set_location('Entering:'||l_proc, 5);
163 	  --
164 	  hr_utility.set_location(' Leaving:'||l_proc, 10);
165   end if;
166 End pre_update;
167 --
168 -- ----------------------------------------------------------------------------
169 -- |-----------------------------< post_update >------------------------------|
170 -- ----------------------------------------------------------------------------
171 -- {Start Of Comments}
172 --
173 -- Description:
174 --   This private procedure contains any processing which is required after the
175 --   update dml.
176 --
177 -- Prerequisites:
178 --   This is an internal procedure which is called from the upd procedure.
179 --
180 -- In Parameters:
181 --   A Pl/Sql record structure.
182 --
183 -- Post Success:
184 --   Processing continues.
185 --
186 -- Post Failure:
187 --   If an error has occurred, an error message and exception will be raised
188 --   but not handled.
189 --
190 -- Developer Implementation Notes:
191 --   Any post-processing required after the update dml is issued should be
192 --   coded within this procedure. It is important to note that any 3rd party
193 --   maintenance should be reviewed before placing in this procedure.
194 --
195 -- Access Status:
196 --   Internal Row Handler Use Only.
197 --
198 -- {End Of Comments}
199 -- ----------------------------------------------------------------------------
200 Procedure post_update
201   (p_effective_date               in date
202   ,p_rec                          in hxc_hrr_shd.g_rec_type
203   ) is
204 --
205   l_proc  varchar2(72);
206 --
207 Begin
208   if g_debug then
209 	l_proc := g_package||'post_update';
210 	hr_utility.set_location('Entering:'||l_proc, 5);
211   end if;
212   begin
213     --
214     hxc_hrr_rku.after_update
215       (p_effective_date              => p_effective_date
216       ,p_resource_rule_id
217       => p_rec.resource_rule_id
218       ,p_name
219       => p_rec.name
220        ,p_business_group_id	     => p_rec.business_group_id
221       ,p_legislation_code	     => p_rec.legislation_code
222       ,p_eligibility_criteria_type
223       => p_rec.eligibility_criteria_type
224       ,p_eligibility_criteria_id
225       => p_rec.eligibility_criteria_id
226       ,p_pref_hierarchy_id
227       => p_rec.pref_hierarchy_id
228       ,p_rule_evaluation_order
229       => p_rec.rule_evaluation_order
230       ,p_resource_type
231       => p_rec.resource_type
232       ,p_start_date
233       => p_rec.start_date
234       ,p_end_date
235       => p_rec.end_date
236       ,p_object_version_number
237       => p_rec.object_version_number
238       ,p_name_o
239       => hxc_hrr_shd.g_old_rec.name
240       ,p_business_group_id_o	     => hxc_ter_shd.g_old_rec.business_group_id
241       ,p_legislation_code_o	     => hxc_ter_shd.g_old_rec.legislation_code
242       ,p_eligibility_criteria_type_o
243       => hxc_hrr_shd.g_old_rec.eligibility_criteria_type
244       ,p_eligibility_criteria_id_o
245       => hxc_hrr_shd.g_old_rec.eligibility_criteria_id
246       ,p_pref_hierarchy_id_o
247       => hxc_hrr_shd.g_old_rec.pref_hierarchy_id
248       ,p_rule_evaluation_order_o
249       => hxc_hrr_shd.g_old_rec.rule_evaluation_order
250       ,p_resource_type_o
251       => hxc_hrr_shd.g_old_rec.resource_type
252       ,p_start_date_o
253       => hxc_hrr_shd.g_old_rec.start_date
254       ,p_end_date_o
255       => hxc_hrr_shd.g_old_rec.end_date
256       ,p_object_version_number_o
257       => hxc_hrr_shd.g_old_rec.object_version_number
258       );
259     --
260   exception
261     --
262     when hr_api.cannot_find_prog_unit then
263       --
264       hr_api.cannot_find_prog_unit_error
265         (p_module_name => 'HXC_RESOURCE_RULES'
266         ,p_hook_type   => 'AU');
267       --
268   end;
269   --
270   if g_debug then
271 	hr_utility.set_location(' Leaving:'||l_proc, 10);
272   end if;
273 End post_update;
274 --
275 -- ----------------------------------------------------------------------------
276 -- |-----------------------------< convert_defs >-----------------------------|
277 -- ----------------------------------------------------------------------------
278 -- {Start Of Comments}
279 --
280 -- Description:
281 --   The Convert_Defs procedure has one very important function:
282 --   It must return the record structure for the row with all system defaulted
283 --   values converted into its corresponding parameter value for update. When
284 --   we attempt to update a row through the Upd process , certain
285 --   parameters can be defaulted which enables flexibility in the calling of
286 --   the upd process (e.g. only attributes which need to be updated need to be
287 --   specified). For the upd process to determine which attributes
288 --   have NOT been specified we need to check if the parameter has a reserved
289 --   system default value. Therefore, for all parameters which have a
290 --   corresponding reserved system default mechanism specified we need to
291 --   check if a system default is being used. If a system default is being
292 --   used then we convert the defaulted value into its corresponding attribute
293 --   value held in the g_old_rec data structure.
294 --
295 -- Prerequisites:
296 --   This private function can only be called from the upd process.
297 --
298 -- In Parameters:
299 --   A Pl/Sql record structure.
300 --
301 -- Post Success:
302 --   The record structure will be returned with all system defaulted parameter
303 --   values converted into its current row attribute value.
304 --
305 -- Post Failure:
306 --   No direct error handling is required within this function. Any possible
307 --   errors within this procedure will be a PL/SQL value error due to
308 --   conversion of datatypes or data lengths.
309 --
310 -- Developer Implementation Notes:
311 --   None.
312 --
313 -- Access Status:
314 --   Internal Row Handler Use Only.
315 --
316 -- {End Of Comments}
317 -- ----------------------------------------------------------------------------
318 Procedure convert_defs
319   (p_rec in out nocopy hxc_hrr_shd.g_rec_type
320   ) is
321 --
322 Begin
323   --
324   -- We must now examine each argument value in the
325   -- p_rec plsql record structure
326   -- to see if a system default is being used. If a system default
327   -- is being used then we must set to the 'current' argument value.
328   --
329   If (p_rec.name = hr_api.g_varchar2) then
330     p_rec.name :=
331     hxc_hrr_shd.g_old_rec.name;
332   End If;
333   If (p_rec.business_group_id = hr_api.g_number) then
334     p_rec.business_group_id :=
335     hxc_ter_shd.g_old_rec.business_group_id;
336   End If;
337   If (p_rec.legislation_code = hr_api.g_varchar2) then
338     p_rec.legislation_code :=
339     hxc_ter_shd.g_old_rec.legislation_code;
340   End If;
341   If (p_rec.eligibility_criteria_type = hr_api.g_varchar2) then
342     p_rec.eligibility_criteria_type :=
343     hxc_hrr_shd.g_old_rec.eligibility_criteria_type;
344   End If;
345 
346 -- GPM 26-APR-01 115.8
347 -- hr_api.g_number -> hr_api.g_varchar2
348 
349   If (p_rec.eligibility_criteria_id = hr_api.g_varchar2) then
350     p_rec.eligibility_criteria_id :=
351     hxc_hrr_shd.g_old_rec.eligibility_criteria_id;
352   End If;
353   If (p_rec.pref_hierarchy_id = hr_api.g_number) then
354     p_rec.pref_hierarchy_id :=
355     hxc_hrr_shd.g_old_rec.pref_hierarchy_id;
356   End If;
357   If (p_rec.rule_evaluation_order = hr_api.g_number) then
358     p_rec.rule_evaluation_order :=
359     hxc_hrr_shd.g_old_rec.rule_evaluation_order;
360   End If;
361   If (p_rec.resource_type = hr_api.g_varchar2) then
362     p_rec.resource_type :=
363     hxc_hrr_shd.g_old_rec.resource_type;
364   End If;
365   If (p_rec.start_date = hr_api.g_date) then
366     p_rec.start_date :=
367     hxc_hrr_shd.g_old_rec.start_date;
368   End If;
369   If (p_rec.end_date = hr_api.g_date) then
370     p_rec.end_date :=
371     hxc_hrr_shd.g_old_rec.end_date;
372   End If;
373   --
374 End convert_defs;
375 --
376 -- ----------------------------------------------------------------------------
377 -- |---------------------------------< upd >----------------------------------|
378 -- ----------------------------------------------------------------------------
379 Procedure upd
380   (p_effective_date               in date
381   ,p_rec                          in out nocopy hxc_hrr_shd.g_rec_type
382   ) is
383 --
384   l_proc  varchar2(72);
385 --
386 Begin
387   g_debug:=hr_utility.debug_enabled;
388   if g_debug then
389 	l_proc := g_package||'upd';
390 	hr_utility.set_location('Entering:'||l_proc, 5);
391   end if;
392   --
393   -- We must lock the row which we need to update.
394   --
395   hxc_hrr_shd.lck
396     (p_rec.resource_rule_id
397     ,p_rec.object_version_number
398     );
399   --
400   -- 1. During an update system defaults are used to determine if
401   --    arguments have been defaulted or not. We must therefore
402   --    derive the full record structure values to be updated.
403   --
404   -- 2. Call the supporting update validate operations.
405   --
406   convert_defs(p_rec);
407   hxc_hrr_bus.update_validate
408      (p_effective_date
409      ,p_rec
410      );
411   --
412   -- Call the supporting pre-update operation
413   --
414   hxc_hrr_upd.pre_update(p_rec);
415   --
416   -- Update the row.
417   --
418   hxc_hrr_upd.update_dml(p_rec);
419   --
420   -- Call the supporting post-update operation
421   --
422   hxc_hrr_upd.post_update
423      (p_effective_date
424      ,p_rec
425      );
426 End upd;
427 --
428 -- ----------------------------------------------------------------------------
429 -- |---------------------------------< upd >----------------------------------|
430 -- ----------------------------------------------------------------------------
431 Procedure upd
432   (p_effective_date               in     date
433   ,p_resource_rule_id             in     number
434   ,p_object_version_number        in out nocopy number
435   ,p_name                         in     varchar2  default hr_api.g_varchar2
436   ,p_business_group_id             in     number   default hr_api.g_number
437   ,p_legislation_code              in     varchar2 default hr_api.g_varchar2
438   ,p_eligibility_criteria_type    in     varchar2  default hr_api.g_varchar2
439   ,p_eligibility_criteria_id      in     varchar2  default hr_api.g_varchar2
440   ,p_pref_hierarchy_id            in     number    default hr_api.g_number
441   ,p_rule_evaluation_order        in     number    default hr_api.g_number
442   ,p_resource_type                in     varchar2  default hr_api.g_varchar2
443   ,p_start_date                   in     date      default hr_api.g_date
444   ,p_end_date                     in     date      default hr_api.g_date
445   ) is
446 --
447   l_rec	  hxc_hrr_shd.g_rec_type;
448   l_proc  varchar2(72);
449 --
450 Begin
451   g_debug:=hr_utility.debug_enabled;
452   if g_debug then
453 	l_proc := g_package||'upd';
454 	hr_utility.set_location('Entering:'||l_proc, 5);
455   end if;
456   --
457   -- Call conversion function to turn arguments into the
458   -- l_rec structure.
459   --
460   l_rec :=
461   hxc_hrr_shd.convert_args
462   (p_resource_rule_id
463   ,p_name
464   ,p_business_group_id
465   ,p_legislation_code
466   ,p_eligibility_criteria_type
467   ,p_eligibility_criteria_id
468   ,p_pref_hierarchy_id
469   ,p_rule_evaluation_order
470   ,p_resource_type
471   ,p_start_date
472   ,p_end_date
473   ,p_object_version_number
474   );
475   --
476   -- Having converted the arguments into the
477   -- plsql record structure we call the corresponding record
478   -- business process.
479   --
480   hxc_hrr_upd.upd
481      (p_effective_date
482      ,l_rec
483      );
484   p_object_version_number := l_rec.object_version_number;
485   --
486   if g_debug then
487 	hr_utility.set_location(' Leaving:'||l_proc, 10);
488   end if;
489 End upd;
490 --
491 end hxc_hrr_upd;