1 Package Body pqh_rht_upd as
2 /* $Header: pqrhtrhi.pkb 115.7 2002/12/06 18:08:02 rpasapul noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_rht_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 -- 3) To update the specified row in the schema using the primary key in
21 -- the predicates.
22 -- 4) To trap any constraint violations that may have occurred.
23 -- 5) To raise any other errors.
24 --
25 -- Prerequisites:
26 -- This is an internal private procedure which must be called from the upd
27 -- procedure.
28 --
29 -- In Parameters:
30 -- A Pl/Sql record structre.
31 --
32 -- Post Success:
33 -- The specified row will be updated in the schema.
34 --
35 -- Post Failure:
36 -- If a check, unique or parent integrity constraint violation is raised the
37 -- constraint_error procedure will be called.
38 --
39 -- Developer Implementation Notes:
40 -- The update 'set' attribute list should be modified if any of your
41 -- attributes are not updateable.
42 --
43 -- Access Status:
44 -- Internal Row Handler Use Only.
45 --
46 -- {End Of Comments}
47 -- ----------------------------------------------------------------------------
48 Procedure update_dml(p_rec in out nocopy pqh_rht_shd.g_rec_type) is
49 --
50 l_proc varchar2(72) := g_package||'update_dml';
51 --
52 Begin
53 hr_utility.set_location('Entering:'||l_proc, 5);
54 --
55 -- Increment the object version
56 --
57 p_rec.object_version_number := p_rec.object_version_number + 1;
58 --
59 --
60 -- Update the pqh_routing_history Row
61 --
62 update pqh_routing_history
63 set
64 routing_history_id = p_rec.routing_history_id,
65 approval_cd = p_rec.approval_cd,
66 comments = p_rec.comments,
67 forwarded_by_assignment_id = p_rec.forwarded_by_assignment_id,
68 forwarded_by_member_id = p_rec.forwarded_by_member_id,
69 forwarded_by_position_id = p_rec.forwarded_by_position_id,
70 forwarded_by_user_id = p_rec.forwarded_by_user_id,
71 forwarded_by_role_id = p_rec.forwarded_by_role_id,
72 forwarded_to_assignment_id = p_rec.forwarded_to_assignment_id,
73 forwarded_to_member_id = p_rec.forwarded_to_member_id,
74 forwarded_to_position_id = p_rec.forwarded_to_position_id,
75 forwarded_to_user_id = p_rec.forwarded_to_user_id,
76 forwarded_to_role_id = p_rec.forwarded_to_role_id,
77 notification_date = p_rec.notification_date,
78 pos_structure_version_id = p_rec.pos_structure_version_id,
79 routing_category_id = p_rec.routing_category_id,
80 transaction_category_id = p_rec.transaction_category_id,
81 transaction_id = p_rec.transaction_id,
82 user_action_cd = p_rec.user_action_cd,
83 from_range_name = p_rec.from_range_name,
84 to_range_name = p_rec.to_range_name,
85 list_range_name = p_rec.list_range_name,
86 object_version_number = p_rec.object_version_number
87 where routing_history_id = p_rec.routing_history_id;
88 --
89 --
90 hr_utility.set_location(' Leaving:'||l_proc, 10);
91 --
92 Exception
93 When hr_api.check_integrity_violated Then
94 -- A check constraint has been violated
95 pqh_rht_shd.constraint_error
96 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
97 When hr_api.parent_integrity_violated Then
98 -- Parent integrity has been violated
99 pqh_rht_shd.constraint_error
100 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
101 When hr_api.unique_integrity_violated Then
102 -- Unique integrity has been violated
103 pqh_rht_shd.constraint_error
104 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
105 When Others Then
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 structre.
123 --
124 -- Post Success:
125 -- Processing continues.
126 --
127 -- Post Failure:
128 -- If an error has occurred, an error message and exception will 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(p_rec in pqh_rht_shd.g_rec_type) is
142 --
143 l_proc varchar2(72) := g_package||'pre_update';
144 --
145 Begin
146 hr_utility.set_location('Entering:'||l_proc, 5);
147 --
148 hr_utility.set_location(' Leaving:'||l_proc, 10);
149 End pre_update;
150 --
151 -- ----------------------------------------------------------------------------
152 -- |-----------------------------< post_update >------------------------------|
153 -- ----------------------------------------------------------------------------
154 -- {Start Of Comments}
155 --
156 -- Description:
157 -- This private procedure contains any processing which is required after the
158 -- update dml.
159 --
160 -- Prerequisites:
161 -- This is an internal procedure which is called from the upd procedure.
162 --
163 -- In Parameters:
164 -- A Pl/Sql record structre.
165 --
166 -- Post Success:
167 -- Processing continues.
168 --
169 -- Post Failure:
170 -- If an error has occurred, an error message and exception will be raised
171 -- but not handled.
172 --
173 -- Developer Implementation Notes:
174 -- Any post-processing required after the update dml is issued should be
175 -- coded within this procedure. It is important to note that any 3rd party
176 -- maintenance should be reviewed before placing in this procedure.
177 --
178 -- Access Status:
179 -- Internal Row Handler Use Only.
180 --
181 -- {End Of Comments}
182 -- ----------------------------------------------------------------------------
183 Procedure post_update(
184 p_effective_date in date,p_rec in pqh_rht_shd.g_rec_type) is
185 --
186 l_proc varchar2(72) := g_package||'post_update';
187 --
188 Begin
189 hr_utility.set_location('Entering:'||l_proc, 5);
190 --
191 --
192 -- Start of API User Hook for post_update.
193 --
194 begin
195 --
196 pqh_rht_rku.after_update
197 (
198 p_routing_history_id =>p_rec.routing_history_id
199 ,p_approval_cd =>p_rec.approval_cd
200 ,p_comments =>p_rec.comments
201 ,p_forwarded_by_assignment_id =>p_rec.forwarded_by_assignment_id
202 ,p_forwarded_by_member_id =>p_rec.forwarded_by_member_id
203 ,p_forwarded_by_position_id =>p_rec.forwarded_by_position_id
204 ,p_forwarded_by_user_id =>p_rec.forwarded_by_user_id
205 ,p_forwarded_by_role_id =>p_rec.forwarded_by_role_id
206 ,p_forwarded_to_assignment_id =>p_rec.forwarded_to_assignment_id
207 ,p_forwarded_to_member_id =>p_rec.forwarded_to_member_id
208 ,p_forwarded_to_position_id =>p_rec.forwarded_to_position_id
209 ,p_forwarded_to_user_id =>p_rec.forwarded_to_user_id
210 ,p_forwarded_to_role_id =>p_rec.forwarded_to_role_id
211 ,p_notification_date =>p_rec.notification_date
212 ,p_pos_structure_version_id =>p_rec.pos_structure_version_id
213 ,p_routing_category_id =>p_rec.routing_category_id
214 ,p_transaction_category_id =>p_rec.transaction_category_id
215 ,p_transaction_id =>p_rec.transaction_id
216 ,p_user_action_cd =>p_rec.user_action_cd
217 ,p_from_range_name =>p_rec.from_range_name
218 ,p_to_range_name =>p_rec.to_range_name
219 ,p_list_range_name =>p_rec.list_range_name
220 ,p_object_version_number =>p_rec.object_version_number
221 ,p_effective_date =>p_effective_date
222 ,p_approval_cd_o =>pqh_rht_shd.g_old_rec.approval_cd
223 ,p_comments_o =>pqh_rht_shd.g_old_rec.comments
224 ,p_forwarded_by_assignment_id_o =>pqh_rht_shd.g_old_rec.forwarded_by_assignment_id
225 ,p_forwarded_by_member_id_o =>pqh_rht_shd.g_old_rec.forwarded_by_member_id
226 ,p_forwarded_by_position_id_o =>pqh_rht_shd.g_old_rec.forwarded_by_position_id
227 ,p_forwarded_by_user_id_o =>pqh_rht_shd.g_old_rec.forwarded_by_user_id
228 ,p_forwarded_by_role_id_o =>pqh_rht_shd.g_old_rec.forwarded_by_role_id
229 ,p_forwarded_to_assignment_id_o =>pqh_rht_shd.g_old_rec.forwarded_to_assignment_id
230 ,p_forwarded_to_member_id_o =>pqh_rht_shd.g_old_rec.forwarded_to_member_id
231 ,p_forwarded_to_position_id_o =>pqh_rht_shd.g_old_rec.forwarded_to_position_id
232 ,p_forwarded_to_user_id_o =>pqh_rht_shd.g_old_rec.forwarded_to_user_id
233 ,p_forwarded_to_role_id_o =>pqh_rht_shd.g_old_rec.forwarded_to_role_id
234 ,p_notification_date_o =>pqh_rht_shd.g_old_rec.notification_date
235 ,p_pos_structure_version_id_o =>pqh_rht_shd.g_old_rec.pos_structure_version_id
236 ,p_routing_category_id_o =>pqh_rht_shd.g_old_rec.routing_category_id
237 ,p_transaction_category_id_o =>pqh_rht_shd.g_old_rec.transaction_category_id
238 ,p_transaction_id_o =>pqh_rht_shd.g_old_rec.transaction_id
239 ,p_user_action_cd_o =>pqh_rht_shd.g_old_rec.user_action_cd
240 ,p_from_range_name_o =>pqh_rht_shd.g_old_rec.from_range_name
241 ,p_to_range_name_o =>pqh_rht_shd.g_old_rec.to_range_name
242 ,p_list_range_name_o =>pqh_rht_shd.g_old_rec.list_range_name
243 ,p_object_version_number_o =>pqh_rht_shd.g_old_rec.object_version_number
244 );
245 --
246 exception
247 --
248 when hr_api.cannot_find_prog_unit then
249 --
250 hr_api.cannot_find_prog_unit_error
251 (p_module_name => 'pqh_routing_history'
252 ,p_hook_type => 'AU');
253 --
254 end;
255 --
256 -- End of API User Hook for post_update.
257 --
258 --
259 hr_utility.set_location(' Leaving:'||l_proc, 10);
260 End post_update;
261 --
262 -- ----------------------------------------------------------------------------
263 -- |-----------------------------< convert_defs >-----------------------------|
264 -- ----------------------------------------------------------------------------
265 -- {Start Of Comments}
266 --
267 -- Description:
268 -- The Convert_Defs procedure has one very important function:
269 -- It must return the record structure for the row with all system defaulted
270 -- values converted into its corresponding parameter value for update. When
271 -- we attempt to update a row through the Upd process , certain
272 -- parameters can be defaulted which enables flexibility in the calling of
273 -- the upd process (e.g. only attributes which need to be updated need to be
274 -- specified). For the upd process to determine which attributes
275 -- have NOT been specified we need to check if the parameter has a reserved
276 -- system default value. Therefore, for all parameters which have a
277 -- corresponding reserved system default mechanism specified we need to
278 -- check if a system default is being used. If a system default is being
279 -- used then we convert the defaulted value into its corresponding attribute
280 -- value held in the g_old_rec data structure.
281 --
282 -- Prerequisites:
283 -- This private function can only be called from the upd process.
284 --
285 -- In Parameters:
286 -- A Pl/Sql record structre.
287 --
288 -- Post Success:
289 -- The record structure will be returned with all system defaulted parameter
290 -- values converted into its current row attribute value.
291 --
292 -- Post Failure:
293 -- No direct error handling is required within this function. Any possible
294 -- errors within this procedure will be a PL/SQL value error due to conversion
295 -- of datatypes or data lengths.
296 --
297 -- Developer Implementation Notes:
298 -- None.
299 --
300 -- Access Status:
301 -- Internal Row Handler Use Only.
302 --
303 -- {End Of Comments}
304 -- ----------------------------------------------------------------------------
305 Procedure convert_defs(p_rec in out nocopy pqh_rht_shd.g_rec_type) is
306 --
307 l_proc varchar2(72) := g_package||'convert_defs';
308 --
309 Begin
310 --
311 hr_utility.set_location('Entering:'||l_proc, 5);
312 --
313 -- We must now examine each argument value in the
314 -- p_rec plsql record structure
315 -- to see if a system default is being used. If a system default
316 -- is being used then we must set to the 'current' argument value.
317 --
318 If (p_rec.approval_cd = hr_api.g_varchar2) then
319 p_rec.approval_cd :=
320 pqh_rht_shd.g_old_rec.approval_cd;
321 End If;
322 If (p_rec.comments = hr_api.g_varchar2) then
323 p_rec.comments :=
324 pqh_rht_shd.g_old_rec.comments;
325 End If;
326 If (p_rec.forwarded_by_assignment_id = hr_api.g_number) then
327 p_rec.forwarded_by_assignment_id :=
328 pqh_rht_shd.g_old_rec.forwarded_by_assignment_id;
329 End If;
330 If (p_rec.forwarded_by_member_id = hr_api.g_number) then
331 p_rec.forwarded_by_member_id :=
332 pqh_rht_shd.g_old_rec.forwarded_by_member_id;
333 End If;
334 If (p_rec.forwarded_by_position_id = hr_api.g_number) then
335 p_rec.forwarded_by_position_id :=
336 pqh_rht_shd.g_old_rec.forwarded_by_position_id;
337 End If;
338 If (p_rec.forwarded_by_user_id = hr_api.g_number) then
339 p_rec.forwarded_by_user_id :=
340 pqh_rht_shd.g_old_rec.forwarded_by_user_id;
341 End If;
342 If (p_rec.forwarded_by_role_id = hr_api.g_number) then
343 p_rec.forwarded_by_role_id :=
344 pqh_rht_shd.g_old_rec.forwarded_by_role_id;
345 End If;
346 If (p_rec.forwarded_to_assignment_id = hr_api.g_number) then
347 p_rec.forwarded_to_assignment_id :=
348 pqh_rht_shd.g_old_rec.forwarded_to_assignment_id;
349 End If;
350 If (p_rec.forwarded_to_member_id = hr_api.g_number) then
351 p_rec.forwarded_to_member_id :=
352 pqh_rht_shd.g_old_rec.forwarded_to_member_id;
353 End If;
354 If (p_rec.forwarded_to_position_id = hr_api.g_number) then
355 p_rec.forwarded_to_position_id :=
356 pqh_rht_shd.g_old_rec.forwarded_to_position_id;
357 End If;
358 If (p_rec.forwarded_to_user_id = hr_api.g_number) then
359 p_rec.forwarded_to_user_id :=
360 pqh_rht_shd.g_old_rec.forwarded_to_user_id;
361 End If;
362 If (p_rec.forwarded_to_role_id = hr_api.g_number) then
363 p_rec.forwarded_to_role_id :=
364 pqh_rht_shd.g_old_rec.forwarded_to_role_id;
365 End If;
366 If (p_rec.notification_date = hr_api.g_date) then
367 p_rec.notification_date :=
368 pqh_rht_shd.g_old_rec.notification_date;
369 End If;
370 If (p_rec.pos_structure_version_id = hr_api.g_number) then
371 p_rec.pos_structure_version_id :=
372 pqh_rht_shd.g_old_rec.pos_structure_version_id;
373 End If;
374 If (p_rec.routing_category_id = hr_api.g_number) then
375 p_rec.routing_category_id :=
376 pqh_rht_shd.g_old_rec.routing_category_id;
377 End If;
378 If (p_rec.transaction_category_id = hr_api.g_number) then
379 p_rec.transaction_category_id :=
380 pqh_rht_shd.g_old_rec.transaction_category_id;
381 End If;
382 If (p_rec.transaction_id = hr_api.g_number) then
383 p_rec.transaction_id :=
384 pqh_rht_shd.g_old_rec.transaction_id;
385 End If;
386 If (p_rec.user_action_cd = hr_api.g_varchar2) then
387 p_rec.user_action_cd :=
388 pqh_rht_shd.g_old_rec.user_action_cd;
389 End If;
390 If (p_rec.from_range_name = hr_api.g_varchar2) then
391 p_rec.from_range_name :=
392 pqh_rht_shd.g_old_rec.from_range_name;
393 End If;
394 If (p_rec.to_range_name = hr_api.g_varchar2) then
395 p_rec.to_range_name :=
396 pqh_rht_shd.g_old_rec.to_range_name;
397 End If;
398 If (p_rec.list_range_name = hr_api.g_varchar2) then
399 p_rec.list_range_name :=
400 pqh_rht_shd.g_old_rec.list_range_name;
401 End If;
402
403 --
404 hr_utility.set_location(' Leaving:'||l_proc, 10);
405 --
406 End convert_defs;
407 --
408 -- ----------------------------------------------------------------------------
409 -- |---------------------------------< upd >----------------------------------|
410 -- ----------------------------------------------------------------------------
411 Procedure upd
412 (
413 p_effective_date in date,
414 p_rec in out nocopy pqh_rht_shd.g_rec_type
415 ) is
416 --
417 l_proc varchar2(72) := g_package||'upd';
418 --
419 Begin
420 hr_utility.set_location('Entering:'||l_proc, 5);
421 --
422 -- We must lock the row which we need to update.
423 --
424 pqh_rht_shd.lck
425 (
426 p_rec.routing_history_id,
427 p_rec.object_version_number
428 );
429 --
430 -- 1. During an update system defaults are used to determine if
431 -- arguments have been defaulted or not. We must therefore
432 -- derive the full record structure values to be updated.
433 --
434 -- 2. Call the supporting update validate operations.
435 --
436 convert_defs(p_rec);
437 pqh_rht_bus.update_validate(p_rec
438 ,p_effective_date);
439 --
440 -- Call the supporting pre-update operation
441 --
442 pre_update(p_rec);
443 --
444 -- Update the row.
445 --
446 update_dml(p_rec);
447 --
448 -- Call the supporting post-update operation
449 --
450 post_update(
451 p_effective_date,p_rec);
452 End upd;
453 --
454 -- ----------------------------------------------------------------------------
455 -- |---------------------------------< upd >----------------------------------|
456 -- ----------------------------------------------------------------------------
457 Procedure upd
458 (
459 p_effective_date in date,
460 p_routing_history_id in number,
461 p_approval_cd in varchar2 default hr_api.g_varchar2,
462 p_comments in varchar2 default hr_api.g_varchar2,
463 p_forwarded_by_assignment_id in number default hr_api.g_number,
464 p_forwarded_by_member_id in number default hr_api.g_number,
465 p_forwarded_by_position_id in number default hr_api.g_number,
466 p_forwarded_by_user_id in number default hr_api.g_number,
467 p_forwarded_by_role_id in number default hr_api.g_number,
468 p_forwarded_to_assignment_id in number default hr_api.g_number,
469 p_forwarded_to_member_id in number default hr_api.g_number,
470 p_forwarded_to_position_id in number default hr_api.g_number,
471 p_forwarded_to_user_id in number default hr_api.g_number,
472 p_forwarded_to_role_id in number default hr_api.g_number,
473 p_notification_date in date default hr_api.g_date,
474 p_pos_structure_version_id in number default hr_api.g_number,
475 p_routing_category_id in number default hr_api.g_number,
476 p_transaction_category_id in number default hr_api.g_number,
477 p_transaction_id in number default hr_api.g_number,
478 p_user_action_cd in varchar2 default hr_api.g_varchar2,
479 p_from_range_name in varchar2 default hr_api.g_varchar2,
480 p_to_range_name in varchar2 default hr_api.g_varchar2,
481 p_list_range_name in varchar2 default hr_api.g_varchar2,
482 p_object_version_number in out nocopy number
483 ) is
484 --
485 l_rec pqh_rht_shd.g_rec_type;
486 l_proc varchar2(72) := g_package||'upd';
487 --
488 Begin
489 hr_utility.set_location('Entering:'||l_proc, 5);
490 --
491 -- Call conversion function to turn arguments into the
492 -- l_rec structure.
493 --
494 l_rec :=
495 pqh_rht_shd.convert_args
496 (
497 p_routing_history_id,
498 p_approval_cd,
499 p_comments,
500 p_forwarded_by_assignment_id,
501 p_forwarded_by_member_id,
502 p_forwarded_by_position_id,
503 p_forwarded_by_user_id,
504 p_forwarded_by_role_id,
505 p_forwarded_to_assignment_id,
506 p_forwarded_to_member_id,
507 p_forwarded_to_position_id,
508 p_forwarded_to_user_id,
509 p_forwarded_to_role_id,
510 p_notification_date,
511 p_pos_structure_version_id,
512 p_routing_category_id,
513 p_transaction_category_id,
514 p_transaction_id,
515 p_user_action_cd,
516 p_from_range_name,
517 p_to_range_name,
518 p_list_range_name,
519 p_object_version_number
520 );
521 --
522 -- Having converted the arguments into the
523 -- plsql record structure we call the corresponding record
524 -- business process.
525 --
526 upd(
527 p_effective_date,l_rec);
528 p_object_version_number := l_rec.object_version_number;
529 --
530 hr_utility.set_location(' Leaving:'||l_proc, 10);
531 End upd;
532 --
533 end pqh_rht_upd;