DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_ASP_UPD

Source


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