DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_ENT_UPD

Source


1 Package Body per_ent_upd as
2 /* $Header: peentrhi.pkb 120.2 2005/06/16 08:27:40 vegopala noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  per_ent_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 per_ent_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 per_calendar_entries Row
69   update per_calendar_entries
70     set
71      calendar_entry_id               = p_rec.calendar_entry_id
72     ,name                            = p_rec.name
73     ,type                            = p_rec.type
74     ,start_date                      = p_rec.start_date
75     ,start_hour                      = p_rec.start_hour
76     ,start_min                       = p_rec.start_min
77     ,end_date                        = p_rec.end_date
78     ,end_hour                        = p_rec.end_hour
79     ,end_min                         = p_rec.end_min
80     ,description                     = p_rec.description
81     ,hierarchy_id                    = p_rec.hierarchy_id
82     ,value_set_id                    = p_rec.value_set_id
83     ,organization_structure_id       = p_rec.organization_structure_id
84     ,org_structure_version_id        = p_rec.org_structure_version_id
85     ,object_version_number           = p_rec.object_version_number
86     ,business_group_id               = p_rec.business_group_id
87     where calendar_entry_id = p_rec.calendar_entry_id;
88 
89   --
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     per_ent_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     per_ent_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     per_ent_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 per_ent_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 per_ent_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     per_ent_rku.after_update
204       (p_effective_date
205       => p_effective_date
206       ,p_calendar_entry_id
207       => p_rec.calendar_entry_id
208       ,p_business_group_id
209       => p_rec.business_group_id
210       ,p_name
211       => p_rec.name
212       ,p_type
213       => p_rec.type
214       ,p_start_date
215       => p_rec.start_date
216       ,p_start_hour
217       => p_rec.start_hour
218       ,p_start_min
219       => p_rec.start_min
220       ,p_end_date
221       => p_rec.end_date
222       ,p_end_hour
223       => p_rec.end_hour
224       ,p_end_min
225       => p_rec.end_min
226       ,p_description
227       => p_rec.description
228       ,p_hierarchy_id
229       => p_rec.hierarchy_id
230       ,p_value_set_id
231       => p_rec.value_set_id
232       ,p_organization_structure_id
233       => p_rec.organization_structure_id
234       ,p_org_structure_version_id
235       => p_rec.org_structure_version_id
236       ,p_object_version_number
237       => p_rec.object_version_number
238       ,p_business_group_id_o
239       => per_ent_shd.g_old_rec.business_group_id
240       ,p_name_o
241       => per_ent_shd.g_old_rec.name
242       ,p_type_o
243       => per_ent_shd.g_old_rec.type
244       ,p_start_date_o
245       => per_ent_shd.g_old_rec.start_date
246       ,p_start_hour_o
247       => per_ent_shd.g_old_rec.start_hour
248       ,p_start_min_o
249       => per_ent_shd.g_old_rec.start_min
250       ,p_end_date_o
251       => per_ent_shd.g_old_rec.end_date
252       ,p_end_hour_o
253       => per_ent_shd.g_old_rec.end_hour
254       ,p_end_min_o
255       => per_ent_shd.g_old_rec.end_min
256       ,p_description_o
257       => per_ent_shd.g_old_rec.description
258       ,p_hierarchy_id_o
259       => per_ent_shd.g_old_rec.hierarchy_id
260       ,p_value_set_id_o
261       => per_ent_shd.g_old_rec.value_set_id
262       ,p_organization_structure_id_o
263       => per_ent_shd.g_old_rec.organization_structure_id
264       ,p_org_structure_version_id_o
265       => per_ent_shd.g_old_rec.org_structure_version_id
266       ,p_object_version_number_o
267       => per_ent_shd.g_old_rec.object_version_number
268       );
269     --
270   exception
271     --
272     when hr_api.cannot_find_prog_unit then
273       --
274       hr_api.cannot_find_prog_unit_error
275         (p_module_name => 'PER_CALENDAR_ENTRIES'
276         ,p_hook_type   => 'AU');
277       --
278   end;
279   --
280   hr_utility.set_location(' Leaving:'||l_proc, 10);
281 End post_update;
282 --
283 -- ----------------------------------------------------------------------------
284 -- |-----------------------------< convert_defs >-----------------------------|
285 -- ----------------------------------------------------------------------------
286 -- {Start Of Comments}
287 --
288 -- Description:
289 --   The Convert_Defs procedure has one very important function:
290 --   It must return the record structure for the row with all system defaulted
291 --   values converted into its corresponding parameter value for update. When
292 --   we attempt to update a row through the Upd process , certain
293 --   parameters can be defaulted which enables flexibility in the calling of
294 --   the upd process (e.g. only attributes which need to be updated need to be
295 --   specified). For the upd process to determine which attributes
296 --   have NOT been specified we need to check if the parameter has a reserved
297 --   system default value. Therefore, for all parameters which have a
298 --   corresponding reserved system default mechanism specified we need to
299 --   check if a system default is being used. If a system default is being
300 --   used then we convert the defaulted value into its corresponding attribute
301 --   value held in the g_old_rec data structure.
302 --
303 -- Prerequisites:
304 --   This private function can only be called from the upd process.
305 --
306 -- In Parameters:
307 --   A Pl/Sql record structure.
308 --
309 -- Post Success:
310 --   The record structure will be returned with all system defaulted parameter
311 --   values converted into its current row attribute value.
312 --
313 -- Post Failure:
314 --   No direct error handling is required within this function. Any possible
315 --   errors within this procedure will be a PL/SQL value error due to
316 --   conversion of datatypes or data lengths.
317 --
318 -- Developer Implementation Notes:
319 --   None.
320 --
321 -- Access Status:
322 --   Internal Row Handler Use Only.
323 --
324 -- {End Of Comments}
325 -- ----------------------------------------------------------------------------
326 Procedure convert_defs
327   (p_rec in out nocopy per_ent_shd.g_rec_type
328   ) is
329 --
330 Begin
331   --
332   -- We must now examine each argument value in the
333   -- p_rec plsql record structure
334   -- to see if a system default is being used. If a system default
335   -- is being used then we must set to the 'current' argument value.
336   --
337   If (p_rec.business_group_id = hr_api.g_number) then
338     p_rec.business_group_id :=
339     per_ent_shd.g_old_rec.business_group_id;
340   End If;
341   If (p_rec.name = hr_api.g_varchar2) then
342     p_rec.name :=
343     per_ent_shd.g_old_rec.name;
344   End If;
345   If (p_rec.type = hr_api.g_varchar2) then
346     p_rec.type :=
347     per_ent_shd.g_old_rec.type;
348   End If;
349   If (p_rec.start_date = hr_api.g_date) then
350     p_rec.start_date :=
351     per_ent_shd.g_old_rec.start_date;
352   End If;
353   If (p_rec.start_hour = hr_api.g_varchar2) then
354     p_rec.start_hour :=
355     per_ent_shd.g_old_rec.start_hour;
356   End If;
357   If (p_rec.start_min = hr_api.g_varchar2) then
358     p_rec.start_min :=
359     per_ent_shd.g_old_rec.start_min;
360   End If;
361   If (p_rec.end_date = hr_api.g_date) then
362     p_rec.end_date :=
363     per_ent_shd.g_old_rec.end_date;
364   End If;
365   If (p_rec.end_hour = hr_api.g_varchar2) then
366     p_rec.end_hour :=
367     per_ent_shd.g_old_rec.end_hour;
368   End If;
369   If (p_rec.end_min = hr_api.g_varchar2) then
370     p_rec.end_min :=
371     per_ent_shd.g_old_rec.end_min;
372   End If;
373   If (p_rec.description = hr_api.g_varchar2) then
374     p_rec.description :=
375     per_ent_shd.g_old_rec.description;
376   End If;
377   If (p_rec.hierarchy_id = hr_api.g_number) then
378     p_rec.hierarchy_id :=
379     per_ent_shd.g_old_rec.hierarchy_id;
380   End If;
381   If (p_rec.value_set_id = hr_api.g_number) then
382     p_rec.value_set_id :=
383     per_ent_shd.g_old_rec.value_set_id;
384   End If;
385   If (p_rec.organization_structure_id = hr_api.g_number) then
386     p_rec.organization_structure_id :=
387     per_ent_shd.g_old_rec.organization_structure_id;
388   End If;
389   If (p_rec.org_structure_version_id = hr_api.g_number) then
390     p_rec.org_structure_version_id :=
391     per_ent_shd.g_old_rec.org_structure_version_id;
392   End If;
393   If (p_rec.legislation_code = hr_api.g_varchar2) then
394     p_rec.legislation_code :=
395     per_ent_shd.g_old_rec.legislation_code;
396   End If;
397   If (p_rec.identifier_key = hr_api.g_varchar2) then
398     p_rec.identifier_key :=
399     per_ent_shd.g_old_rec.identifier_key;
400   End If;
401   --
402 End convert_defs;
403 --
404 -- ----------------------------------------------------------------------------
405 -- |---------------------------------< upd >----------------------------------|
406 -- ----------------------------------------------------------------------------
407 Procedure upd
408   (p_effective_date               in date
409   ,p_rec                          in out nocopy per_ent_shd.g_rec_type
410   ) is
411 --
412   l_proc  varchar2(72) := g_package||'upd';
413 --
414 Begin
415   hr_utility.set_location('Entering:'||l_proc, 5);
416   --
417   -- We must lock the row which we need to update.
418   --
419   per_ent_shd.lck
420     (p_rec.calendar_entry_id
421     ,p_rec.object_version_number
422     );
423   --
424   -- 1. During an update system defaults are used to determine if
425   --    arguments have been defaulted or not. We must therefore
426   --    derive the full record structure values to be updated.
427   --
428   -- 2. Call the supporting update validate operations.
429   --
430   convert_defs(p_rec);
431   per_ent_bus.update_validate
432      (p_effective_date
433      ,p_rec
434      );
435   --
436   -- Call to raise any errors on multi-message list
437   hr_multi_message.end_validation_set;
438   --
439   -- Call the supporting pre-update operation
440   --
441   per_ent_upd.pre_update(p_rec);
442   --
443   -- Update the row.
444   --
445   per_ent_upd.update_dml(p_rec);
446   --
447   -- Call the supporting post-update operation
448   --
449   per_ent_upd.post_update
450      (p_effective_date
451      ,p_rec
452      );
453   --
454   -- Call to raise any errors on multi-message list
455   hr_multi_message.end_validation_set;
456 End upd;
457 --
458 -- ----------------------------------------------------------------------------
459 -- |---------------------------------< upd >----------------------------------|
460 -- ----------------------------------------------------------------------------
461 Procedure upd
462   (p_effective_date               in     date
463   ,p_calendar_entry_id            in     number
464   ,p_object_version_number        in out nocopy number
465   ,p_name                         in     varchar2  default hr_api.g_varchar2
466   ,p_type                         in     varchar2  default hr_api.g_varchar2
467   ,p_start_date                   in     date      default hr_api.g_date
468   ,p_start_hour                   in     varchar2  default hr_api.g_varchar2
469   ,p_start_min                    in     varchar2  default hr_api.g_varchar2
470   ,p_end_date                     in     date      default hr_api.g_date
471   ,p_end_hour                     in     varchar2  default hr_api.g_varchar2
472   ,p_end_min                      in     varchar2  default hr_api.g_varchar2
473   ,p_description                  in     varchar2  default hr_api.g_varchar2
474   ,p_hierarchy_id                 in     number    default hr_api.g_number
475   ,p_value_set_id                 in     number    default hr_api.g_number
476   ,p_organization_structure_id    in     number    default hr_api.g_number
477   ,p_org_structure_version_id     in     number    default hr_api.g_number
478   ,p_business_group_id             in     number   default null
479   ) is
480 --
481   l_rec   per_ent_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   per_ent_shd.convert_args
492   (p_calendar_entry_id
493   ,p_business_group_id
494   ,p_name
495   ,p_type
496   ,p_start_date
497   ,p_start_hour
498   ,p_start_min
499   ,p_end_date
500   ,p_end_hour
501   ,p_end_min
502   ,p_description
503   ,p_hierarchy_id
504   ,p_value_set_id
505   ,p_organization_structure_id
506   ,p_org_structure_version_id
507   ,hr_api.g_varchar2
508   ,hr_api.g_varchar2
509   ,p_object_version_number
510   );
511   --
512   -- Having converted the arguments into the
513   -- plsql record structure we call the corresponding record
514   -- business process.
515   --
516   per_ent_upd.upd
517      (p_effective_date
518      ,l_rec
519      );
520   p_object_version_number := l_rec.object_version_number;
521   --
522   hr_utility.set_location(' Leaving:'||l_proc, 10);
523 End upd;
524 --
525 end per_ent_upd;