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