1 Package Body ota_lci_upd as
2 /* $Header: otlcirhi.pkb 120.1 2006/10/09 11:53:51 sschauha noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ota_lci_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 ota_lci_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 ota_lp_cat_inclusions Row
69 --
70 update ota_lp_cat_inclusions
71 set
72 learning_path_id = p_rec.learning_path_id
73 ,category_usage_id = p_rec.category_usage_id
74 ,primary_flag = p_rec.primary_flag
75 ,start_date_active = p_rec.start_date_active
76 ,end_date_active = p_rec.end_date_active
77 ,object_version_number = p_rec.object_version_number
78 ,attribute_category = p_rec.attribute_category
79 ,attribute1 = p_rec.attribute1
80 ,attribute2 = p_rec.attribute2
81 ,attribute3 = p_rec.attribute3
82 ,attribute4 = p_rec.attribute4
83 ,attribute5 = p_rec.attribute5
84 ,attribute6 = p_rec.attribute6
85 ,attribute7 = p_rec.attribute7
86 ,attribute8 = p_rec.attribute8
87 ,attribute9 = p_rec.attribute9
88 ,attribute10 = p_rec.attribute10
89 ,attribute11 = p_rec.attribute11
90 ,attribute12 = p_rec.attribute12
91 ,attribute13 = p_rec.attribute13
92 ,attribute14 = p_rec.attribute14
93 ,attribute15 = p_rec.attribute15
94 ,attribute16 = p_rec.attribute16
95 ,attribute17 = p_rec.attribute17
96 ,attribute18 = p_rec.attribute18
97 ,attribute19 = p_rec.attribute19
98 ,attribute20 = p_rec.attribute20
99 where learning_path_id = p_rec.learning_path_id
100 and category_usage_id = p_rec.category_usage_id;
101 --
102 --
103 --
104 hr_utility.set_location(' Leaving:'||l_proc, 10);
105 --
106 Exception
107 When hr_api.check_integrity_violated Then
108 -- A check constraint has been violated
109 --
110 ota_lci_shd.constraint_error
111 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
112 When hr_api.parent_integrity_violated Then
113 -- Parent integrity has been violated
114 --
115 ota_lci_shd.constraint_error
116 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
117 When hr_api.unique_integrity_violated Then
118 -- Unique integrity has been violated
119 --
120 ota_lci_shd.constraint_error
121 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
122 When Others Then
123 --
124 Raise;
125 End update_dml;
126 --
127 -- ----------------------------------------------------------------------------
128 -- |------------------------------< pre_update >------------------------------|
129 -- ----------------------------------------------------------------------------
130 -- {Start Of Comments}
131 --
132 -- Description:
133 -- This private procedure contains any processing which is required before
134 -- the update dml.
135 --
136 -- Prerequisites:
137 -- This is an internal procedure which is called from the upd procedure.
138 --
139 -- In Parameters:
140 -- A Pl/Sql record structure.
141 --
142 -- Post Success:
143 -- Processing continues.
144 --
145 -- Post Failure:
146 -- If an error has occurred, an error message and exception wil be raised
147 -- but not handled.
148 --
149 -- Developer Implementation Notes:
150 -- Any pre-processing required before the update dml is issued should be
151 -- coded within this procedure. It is important to note that any 3rd party
152 -- maintenance should be reviewed before placing in this procedure.
153 --
154 -- Access Status:
155 -- Internal Row Handler Use Only.
156 --
157 -- {End Of Comments}
158 -- ----------------------------------------------------------------------------
159 Procedure pre_update
160 (p_rec in ota_lci_shd.g_rec_type
161 ) is
162 --
163 l_proc varchar2(72) := g_package||'pre_update';
164 --
165 Begin
166 hr_utility.set_location('Entering:'||l_proc, 5);
167 --
168 hr_utility.set_location(' Leaving:'||l_proc, 10);
169 End pre_update;
170 --
171 -- ----------------------------------------------------------------------------
172 -- |-----------------------------< post_update >------------------------------|
173 -- ----------------------------------------------------------------------------
174 -- {Start Of Comments}
175 --
176 -- Description:
177 -- This private procedure contains any processing which is required after
178 -- the update dml.
179 --
180 -- Prerequisites:
181 -- This is an internal procedure which is called from the upd procedure.
182 --
183 -- In Parameters:
184 -- A Pl/Sql record structure.
185 --
186 -- Post Success:
187 -- Processing continues.
188 --
189 -- Post Failure:
190 -- If an error has occurred, an error message and exception will be raised
191 -- but not handled.
192 --
193 -- Developer Implementation Notes:
194 -- Any post-processing required after the update dml is issued should be
195 -- coded within this procedure. It is important to note that any 3rd party
196 -- maintenance should be reviewed before placing in this procedure.
197 --
198 -- Access Status:
199 -- Internal Row Handler Use Only.
200 --
201 -- {End Of Comments}
202 -- ----------------------------------------------------------------------------
203 Procedure post_update
204 (p_effective_date in date
205 ,p_rec in ota_lci_shd.g_rec_type
206 ) is
207 --
208 l_proc varchar2(72) := g_package||'post_update';
209 --
210 Begin
211 hr_utility.set_location('Entering:'||l_proc, 5);
212 begin
213 --
214 ota_lci_rku.after_update
215 (p_effective_date => p_effective_date
216 ,p_learning_path_id
217 => p_rec.learning_path_id
218 ,p_category_usage_id
219 => p_rec.category_usage_id
220 ,p_primary_flag
221 => p_rec.primary_flag
222 ,p_start_date_active
223 => p_rec.start_date_active
224 ,p_end_date_active
225 => p_rec.end_date_active
226 ,p_object_version_number
227 => p_rec.object_version_number
228 ,p_attribute_category
229 => p_rec.attribute_category
230 ,p_attribute1
231 => p_rec.attribute1
232 ,p_attribute2
233 => p_rec.attribute2
234 ,p_attribute3
235 => p_rec.attribute3
236 ,p_attribute4
237 => p_rec.attribute4
238 ,p_attribute5
239 => p_rec.attribute5
240 ,p_attribute6
241 => p_rec.attribute6
242 ,p_attribute7
243 => p_rec.attribute7
244 ,p_attribute8
245 => p_rec.attribute8
246 ,p_attribute9
247 => p_rec.attribute9
248 ,p_attribute10
249 => p_rec.attribute10
250 ,p_attribute11
251 => p_rec.attribute11
252 ,p_attribute12
253 => p_rec.attribute12
254 ,p_attribute13
255 => p_rec.attribute13
256 ,p_attribute14
257 => p_rec.attribute14
258 ,p_attribute15
259 => p_rec.attribute15
260 ,p_attribute16
261 => p_rec.attribute16
262 ,p_attribute17
263 => p_rec.attribute17
264 ,p_attribute18
265 => p_rec.attribute18
266 ,p_attribute19
267 => p_rec.attribute19
268 ,p_attribute20
269 => p_rec.attribute20
270 ,p_primary_flag_o
271 => ota_lci_shd.g_old_rec.primary_flag
272 ,p_start_date_active_o
273 => ota_lci_shd.g_old_rec.start_date_active
274 ,p_end_date_active_o
275 => ota_lci_shd.g_old_rec.end_date_active
276 ,p_object_version_number_o
277 => ota_lci_shd.g_old_rec.object_version_number
278 ,p_attribute_category_o
279 => ota_lci_shd.g_old_rec.attribute_category
280 ,p_attribute1_o
281 => ota_lci_shd.g_old_rec.attribute1
282 ,p_attribute2_o
283 => ota_lci_shd.g_old_rec.attribute2
284 ,p_attribute3_o
285 => ota_lci_shd.g_old_rec.attribute3
286 ,p_attribute4_o
287 => ota_lci_shd.g_old_rec.attribute4
288 ,p_attribute5_o
289 => ota_lci_shd.g_old_rec.attribute5
290 ,p_attribute6_o
291 => ota_lci_shd.g_old_rec.attribute6
292 ,p_attribute7_o
293 => ota_lci_shd.g_old_rec.attribute7
294 ,p_attribute8_o
295 => ota_lci_shd.g_old_rec.attribute8
296 ,p_attribute9_o
297 => ota_lci_shd.g_old_rec.attribute9
298 ,p_attribute10_o
299 => ota_lci_shd.g_old_rec.attribute10
300 ,p_attribute11_o
301 => ota_lci_shd.g_old_rec.attribute11
302 ,p_attribute12_o
303 => ota_lci_shd.g_old_rec.attribute12
304 ,p_attribute13_o
305 => ota_lci_shd.g_old_rec.attribute13
306 ,p_attribute14_o
307 => ota_lci_shd.g_old_rec.attribute14
308 ,p_attribute15_o
309 => ota_lci_shd.g_old_rec.attribute15
310 ,p_attribute16_o
311 => ota_lci_shd.g_old_rec.attribute16
312 ,p_attribute17_o
313 => ota_lci_shd.g_old_rec.attribute17
314 ,p_attribute18_o
315 => ota_lci_shd.g_old_rec.attribute18
316 ,p_attribute19_o
317 => ota_lci_shd.g_old_rec.attribute19
318 ,p_attribute20_o
319 => ota_lci_shd.g_old_rec.attribute20
320 );
321 --
322 exception
323 --
324 when hr_api.cannot_find_prog_unit then
325 --
326 hr_api.cannot_find_prog_unit_error
327 (p_module_name => 'OTA_LP_CAT_INCLUSIONS'
328 ,p_hook_type => 'AU');
329 --
330 end;
331 --
332 hr_utility.set_location(' Leaving:'||l_proc, 10);
333 End post_update;
334 --
335 -- ----------------------------------------------------------------------------
336 -- |-----------------------------< convert_defs >-----------------------------|
337 -- ----------------------------------------------------------------------------
338 -- {Start Of Comments}
339 --
340 -- Description:
341 -- The Convert_Defs procedure has one very important function:
342 -- It must return the record structure for the row with all system defaulted
343 -- values converted into its corresponding parameter value for update. When
344 -- we attempt to update a row through the Upd process , certain
345 -- parameters can be defaulted which enables flexibility in the calling of
346 -- the upd process (e.g. only attributes which need to be updated need to be
347 -- specified). For the upd process to determine which attributes
348 -- have NOT been specified we need to check if the parameter has a reserved
349 -- system default value. Therefore, for all parameters which have a
350 -- corresponding reserved system default mechanism specified we need to
351 -- check if a system default is being used. If a system default is being
352 -- used then we convert the defaulted value into its corresponding attribute
353 -- value held in the g_old_rec data structure.
354 --
355 -- Prerequisites:
356 -- This private function can only be called from the upd process.
357 --
358 -- In Parameters:
359 -- A Pl/Sql record structure.
360 --
361 -- Post Success:
362 -- The record structure will be returned with all system defaulted parameter
363 -- values converted into its current row attribute value.
364 --
365 -- Post Failure:
366 -- No direct error handling is required within this function. Any possible
367 -- errors within this procedure will be a PL/SQL value error due to
368 -- conversion of datatypes or data lengths.
369 --
370 -- Developer Implementation Notes:
371 -- None.
372 --
373 -- Access Status:
374 -- Internal Row Handler Use Only.
375 --
376 -- {End Of Comments}
377 -- ----------------------------------------------------------------------------
378 Procedure convert_defs
379 (p_rec in out nocopy ota_lci_shd.g_rec_type
380 ) is
381 --
382 Begin
383 --
384 -- We must now examine each argument value in the
385 -- p_rec plsql record structure
386 -- to see if a system default is being used. If a system default
387 -- is being used then we must set to the 'current' argument value.
388 --
389 If (p_rec.primary_flag = hr_api.g_varchar2) then
390 p_rec.primary_flag :=
391 ota_lci_shd.g_old_rec.primary_flag;
392 End If;
393 If (p_rec.start_date_active = hr_api.g_date) then
394 p_rec.start_date_active :=
395 ota_lci_shd.g_old_rec.start_date_active;
396 End If;
397 If (p_rec.end_date_active = hr_api.g_date) then
398 p_rec.end_date_active :=
399 ota_lci_shd.g_old_rec.end_date_active;
400 End If;
401 If (p_rec.attribute_category = hr_api.g_varchar2) then
402 p_rec.attribute_category :=
403 ota_lci_shd.g_old_rec.attribute_category;
404 End If;
405 If (p_rec.attribute1 = hr_api.g_varchar2) then
406 p_rec.attribute1 :=
407 ota_lci_shd.g_old_rec.attribute1;
408 End If;
409 If (p_rec.attribute2 = hr_api.g_varchar2) then
410 p_rec.attribute2 :=
411 ota_lci_shd.g_old_rec.attribute2;
412 End If;
413 If (p_rec.attribute3 = hr_api.g_varchar2) then
414 p_rec.attribute3 :=
415 ota_lci_shd.g_old_rec.attribute3;
416 End If;
417 If (p_rec.attribute4 = hr_api.g_varchar2) then
418 p_rec.attribute4 :=
419 ota_lci_shd.g_old_rec.attribute4;
420 End If;
421 If (p_rec.attribute5 = hr_api.g_varchar2) then
422 p_rec.attribute5 :=
423 ota_lci_shd.g_old_rec.attribute5;
424 End If;
425 If (p_rec.attribute6 = hr_api.g_varchar2) then
426 p_rec.attribute6 :=
427 ota_lci_shd.g_old_rec.attribute6;
428 End If;
429 If (p_rec.attribute7 = hr_api.g_varchar2) then
430 p_rec.attribute7 :=
431 ota_lci_shd.g_old_rec.attribute7;
432 End If;
433 If (p_rec.attribute8 = hr_api.g_varchar2) then
434 p_rec.attribute8 :=
435 ota_lci_shd.g_old_rec.attribute8;
436 End If;
437 If (p_rec.attribute9 = hr_api.g_varchar2) then
438 p_rec.attribute9 :=
439 ota_lci_shd.g_old_rec.attribute9;
440 End If;
441 If (p_rec.attribute10 = hr_api.g_varchar2) then
442 p_rec.attribute10 :=
443 ota_lci_shd.g_old_rec.attribute10;
444 End If;
445 If (p_rec.attribute11 = hr_api.g_varchar2) then
446 p_rec.attribute11 :=
447 ota_lci_shd.g_old_rec.attribute11;
448 End If;
449 If (p_rec.attribute12 = hr_api.g_varchar2) then
450 p_rec.attribute12 :=
451 ota_lci_shd.g_old_rec.attribute12;
452 End If;
453 If (p_rec.attribute13 = hr_api.g_varchar2) then
454 p_rec.attribute13 :=
455 ota_lci_shd.g_old_rec.attribute13;
456 End If;
457 If (p_rec.attribute14 = hr_api.g_varchar2) then
458 p_rec.attribute14 :=
459 ota_lci_shd.g_old_rec.attribute14;
460 End If;
461 If (p_rec.attribute15 = hr_api.g_varchar2) then
462 p_rec.attribute15 :=
463 ota_lci_shd.g_old_rec.attribute15;
464 End If;
465 If (p_rec.attribute16 = hr_api.g_varchar2) then
466 p_rec.attribute16 :=
467 ota_lci_shd.g_old_rec.attribute16;
468 End If;
469 If (p_rec.attribute17 = hr_api.g_varchar2) then
470 p_rec.attribute17 :=
471 ota_lci_shd.g_old_rec.attribute17;
472 End If;
473 If (p_rec.attribute18 = hr_api.g_varchar2) then
474 p_rec.attribute18 :=
475 ota_lci_shd.g_old_rec.attribute18;
476 End If;
477 If (p_rec.attribute19 = hr_api.g_varchar2) then
478 p_rec.attribute19 :=
479 ota_lci_shd.g_old_rec.attribute19;
480 End If;
481 If (p_rec.attribute20 = hr_api.g_varchar2) then
482 p_rec.attribute20 :=
483 ota_lci_shd.g_old_rec.attribute20;
484 End If;
485 --
486 End convert_defs;
487 --
488 -- ----------------------------------------------------------------------------
489 -- |---------------------------------< upd >----------------------------------|
490 -- ----------------------------------------------------------------------------
491 Procedure upd
492 (p_effective_date in date
493 ,p_rec in out nocopy ota_lci_shd.g_rec_type
494 ) is
495 --
496 l_proc varchar2(72) := g_package||'upd';
497 --
498 Begin
499 hr_utility.set_location('Entering:'||l_proc, 5);
500 --
501 -- We must lock the row which we need to update.
502 --
503 ota_lci_shd.lck
504 (p_rec.learning_path_id
505 ,p_rec.category_usage_id
506 ,p_rec.object_version_number
507 );
508 --
509 -- 1. During an update system defaults are used to determine if
510 -- arguments have been defaulted or not. We must therefore
511 -- derive the full record structure values to be updated.
512 --
513 -- 2. Call the supporting update validate operations.
514 --
515 convert_defs(p_rec);
516 ota_lci_bus.update_validate
517 (p_effective_date
518 ,p_rec
519 );
520 --
521 -- Call to raise any errors on multi-message list
522 hr_multi_message.end_validation_set;
523 --
524 -- Call the supporting pre-update operation
525 --
526 ota_lci_upd.pre_update(p_rec);
527 --
528 -- Update the row.
529 --
530 ota_lci_upd.update_dml(p_rec);
531 --
532 -- Call the supporting post-update operation
533 --
534 ota_lci_upd.post_update
535 (p_effective_date
536 ,p_rec
537 );
538 --
539 -- Call to raise any errors on multi-message list
540 hr_multi_message.end_validation_set;
541 End upd;
542 --
543 -- ----------------------------------------------------------------------------
544 -- |---------------------------------< upd >----------------------------------|
545 -- ----------------------------------------------------------------------------
546 Procedure upd
547 (p_effective_date in date
548 ,p_learning_path_id in number
549 ,p_category_usage_id in number
550 ,p_object_version_number in out nocopy number
551 ,p_start_date_active in date default hr_api.g_date
552 ,p_primary_flag in varchar2 default hr_api.g_varchar2
553 ,p_end_date_active in date default hr_api.g_date
554 ,p_attribute_category in varchar2 default hr_api.g_varchar2
555 ,p_attribute1 in varchar2 default hr_api.g_varchar2
556 ,p_attribute2 in varchar2 default hr_api.g_varchar2
557 ,p_attribute3 in varchar2 default hr_api.g_varchar2
558 ,p_attribute4 in varchar2 default hr_api.g_varchar2
559 ,p_attribute5 in varchar2 default hr_api.g_varchar2
560 ,p_attribute6 in varchar2 default hr_api.g_varchar2
561 ,p_attribute7 in varchar2 default hr_api.g_varchar2
562 ,p_attribute8 in varchar2 default hr_api.g_varchar2
563 ,p_attribute9 in varchar2 default hr_api.g_varchar2
564 ,p_attribute10 in varchar2 default hr_api.g_varchar2
565 ,p_attribute11 in varchar2 default hr_api.g_varchar2
566 ,p_attribute12 in varchar2 default hr_api.g_varchar2
567 ,p_attribute13 in varchar2 default hr_api.g_varchar2
568 ,p_attribute14 in varchar2 default hr_api.g_varchar2
569 ,p_attribute15 in varchar2 default hr_api.g_varchar2
570 ,p_attribute16 in varchar2 default hr_api.g_varchar2
571 ,p_attribute17 in varchar2 default hr_api.g_varchar2
572 ,p_attribute18 in varchar2 default hr_api.g_varchar2
573 ,p_attribute19 in varchar2 default hr_api.g_varchar2
574 ,p_attribute20 in varchar2 default hr_api.g_varchar2
575 ) is
576 --
577 l_rec ota_lci_shd.g_rec_type;
578 l_proc varchar2(72) := g_package||'upd';
579 --
580 Begin
581 hr_utility.set_location('Entering:'||l_proc, 5);
582 --
583 -- Call conversion function to turn arguments into the
584 -- l_rec structure.
585 --
586 l_rec :=
587 ota_lci_shd.convert_args
588 (p_learning_path_id
589 ,p_category_usage_id
590 ,p_primary_flag
591 ,p_start_date_active
592 ,p_end_date_active
593 ,p_object_version_number
594 ,p_attribute_category
595 ,p_attribute1
596 ,p_attribute2
597 ,p_attribute3
598 ,p_attribute4
599 ,p_attribute5
600 ,p_attribute6
601 ,p_attribute7
602 ,p_attribute8
603 ,p_attribute9
604 ,p_attribute10
605 ,p_attribute11
606 ,p_attribute12
607 ,p_attribute13
608 ,p_attribute14
609 ,p_attribute15
610 ,p_attribute16
611 ,p_attribute17
612 ,p_attribute18
613 ,p_attribute19
614 ,p_attribute20
615 );
616 --
617 -- Having converted the arguments into the
618 -- plsql record structure we call the corresponding record
619 -- business process.
620 --
621 ota_lci_upd.upd
622 (p_effective_date
623 ,l_rec
624 );
625 p_object_version_number := l_rec.object_version_number;
626 --
627 hr_utility.set_location(' Leaving:'||l_proc, 10);
628 End upd;
629 --
630 end ota_lci_upd;