DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_PSE_UPD

Source


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