1 Package Body ota_tsp_upd as
2 /* $Header: ottsp01t.pkb 120.0 2005/05/29 07:54:07 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ota_tsp_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 functions of this
17 -- procedure are as follows:
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 -- Pre Conditions:
28 -- This is an internal private procedure which must be called from the upd
29 -- procedure.
30 --
31 -- In Arguments:
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' arguments list should be modified if any of your
47 -- attributes are not updateable.
48 --
49 -- Access Status:
50 -- Internal Development Use Only.
51 --
52 -- {End Of Comments}
53 -- ----------------------------------------------------------------------------
54 Procedure update_dml(p_rec in out nocopy ota_tsp_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 ota_tsp_shd.g_api_dml := true; -- Set the api dml status
66 --
67 -- Update the ota_skill_provisions Row
68 --
69 update ota_skill_provisions
70 set
71 skill_provision_id = p_rec.skill_provision_id,
72 activity_version_id = p_rec.activity_version_id,
73 object_version_number = p_rec.object_version_number,
74 type = p_rec.type,
75 comments = p_rec.comments,
76 tsp_information_category = p_rec.tsp_information_category,
77 tsp_information1 = p_rec.tsp_information1,
78 tsp_information2 = p_rec.tsp_information2,
79 tsp_information3 = p_rec.tsp_information3,
80 tsp_information4 = p_rec.tsp_information4,
81 tsp_information5 = p_rec.tsp_information5,
82 tsp_information6 = p_rec.tsp_information6,
83 tsp_information7 = p_rec.tsp_information7,
84 tsp_information8 = p_rec.tsp_information8,
85 tsp_information9 = p_rec.tsp_information9,
86 tsp_information10 = p_rec.tsp_information10,
87 tsp_information11 = p_rec.tsp_information11,
88 tsp_information12 = p_rec.tsp_information12,
89 tsp_information13 = p_rec.tsp_information13,
90 tsp_information14 = p_rec.tsp_information14,
91 tsp_information15 = p_rec.tsp_information15,
92 tsp_information16 = p_rec.tsp_information16,
93 tsp_information17 = p_rec.tsp_information17,
94 tsp_information18 = p_rec.tsp_information18,
95 tsp_information19 = p_rec.tsp_information19,
96 tsp_information20 = p_rec.tsp_information20,
97 analysis_criteria_id = p_rec.analysis_criteria_id
98 where skill_provision_id = p_rec.skill_provision_id;
99 --
100 ota_tsp_shd.g_api_dml := false; -- Unset the api dml status
101 --
102 hr_utility.set_location(' Leaving:'||l_proc, 10);
103 --
104 Exception
105 When hr_api.check_integrity_violated Then
106 -- A check constraint has been violated
107 ota_tsp_shd.g_api_dml := false; -- Unset the api dml status
108 ota_tsp_shd.constraint_error
109 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
110 When hr_api.parent_integrity_violated Then
111 -- Parent integrity has been violated
112 ota_tsp_shd.g_api_dml := false; -- Unset the api dml status
113 ota_tsp_shd.constraint_error
114 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
115 When hr_api.unique_integrity_violated Then
116 -- Unique integrity has been violated
117 ota_tsp_shd.g_api_dml := false; -- Unset the api dml status
118 ota_tsp_shd.constraint_error
119 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
120 When Others Then
121 ota_tsp_shd.g_api_dml := false; -- Unset the api dml status
122 Raise;
123 End update_dml;
124 --
125 -- ----------------------------------------------------------------------------
126 -- |------------------------------< pre_update >------------------------------|
127 -- ----------------------------------------------------------------------------
128 -- {Start Of Comments}
129 --
130 -- Description:
131 -- This private procedure contains any processing which is required before
132 -- the update dml.
133 --
134 -- Pre Conditions:
135 -- This is an internal procedure which is called from the upd procedure.
136 --
137 -- In Arguments:
138 -- A Pl/Sql record structre.
139 --
140 -- Post Success:
141 -- Processing continues.
142 --
143 -- Post Failure:
144 -- If an error has occurred, an error message and exception will be raised
145 -- but not handled.
146 --
147 -- Developer Implementation Notes:
148 -- Any pre-processing required before the update dml is issued should be
149 -- coded within this procedure. It is important to note that any 3rd party
150 -- maintenance should be reviewed before placing in this procedure.
151 --
152 -- Access Status:
153 -- Internal Development Use Only.
154 --
155 -- {End Of Comments}
156 -- ----------------------------------------------------------------------------
157 Procedure pre_update(p_rec in ota_tsp_shd.g_rec_type) is
158 --
159 l_proc varchar2(72) := g_package||'pre_update';
160 --
161 Begin
162 hr_utility.set_location('Entering:'||l_proc, 5);
163 --
164 hr_utility.set_location(' Leaving:'||l_proc, 10);
165 End pre_update;
166 --
167 -- ----------------------------------------------------------------------------
168 -- |-----------------------------< post_update >------------------------------|
169 -- ----------------------------------------------------------------------------
170 -- {Start Of Comments}
171 --
172 -- Description:
173 -- This private procedure contains any processing which is required after the
174 -- update dml.
175 --
176 -- Pre Conditions:
177 -- This is an internal procedure which is called from the upd procedure.
178 --
179 -- In Arguments:
180 -- A Pl/Sql record structre.
181 --
182 -- Post Success:
183 -- Processing continues.
184 --
185 -- Post Failure:
186 -- If an error has occurred, an error message and exception will be raised
187 -- but not handled.
188 --
189 -- Developer Implementation Notes:
190 -- Any post-processing required after the update dml is issued should be
191 -- coded within this procedure. It is important to note that any 3rd party
192 -- maintenance should be reviewed before placing in this procedure.
193 --
194 -- Access Status:
195 -- Internal Development Use Only.
196 --
197 -- {End Of Comments}
198 -- ----------------------------------------------------------------------------
199 Procedure post_update(p_rec in ota_tsp_shd.g_rec_type) is
200 --
201 l_proc varchar2(72) := g_package||'post_update';
202 --
203 Begin
204 hr_utility.set_location('Entering:'||l_proc, 5);
205 --
206 hr_utility.set_location(' Leaving:'||l_proc, 10);
207 End post_update;
208 --
209 -- ----------------------------------------------------------------------------
210 -- |-----------------------------< convert_defs >-----------------------------|
211 -- ----------------------------------------------------------------------------
212 -- {Start Of Comments}
213 --
214 -- Description:
215 -- The Convert_Defs function has one very important function:
216 -- It must return the record structure for the row with all system defaulted
217 -- values converted into its corresponding argument value for update. When
218 -- we attempt to update a row through the Upd business process , certain
219 -- arguments can be defaulted which enables flexibility in the calling of
220 -- the upd process (e.g. only attributes which need to be updated need to be
221 -- specified). For the upd business process to determine which attributes
222 -- have NOT been specified we need to check if the argument has a reserved
223 -- system default value. Therefore, for all attributes which have a
224 -- corresponding reserved system default mechanism specified we need to
225 -- check if a system default is being used. If a system default is being
226 -- used then we convert the defaulted value into its corresponding attribute
227 -- value held in the g_old_rec data structure.
228 --
229 -- Pre Conditions:
230 -- This private function can only be called from the upd process.
231 --
232 -- In Arguments:
233 -- A Pl/Sql record structre.
234 --
235 -- Post Success:
236 -- The record structure will be returned with all system defaulted argument
237 -- values converted into its current row attribute value.
238 --
239 -- Post Failure:
240 -- No direct error handling is required within this function. Any possible
241 -- errors within this function will be a PL/SQL value error due to conversion
242 -- of datatypes or data lengths.
243 --
244 -- Developer Implementation Notes:
245 -- None.
246 --
247 -- Access Status:
248 -- Internal Development Use Only.
249 --
250 -- {End Of Comments}
251 -- ----------------------------------------------------------------------------
252 Function convert_defs(p_rec in out nocopy ota_tsp_shd.g_rec_type)
253 Return ota_tsp_shd.g_rec_type is
254 --
255 l_proc varchar2(72) := g_package||'convert_defs';
256 --
257 Begin
258 --
259 hr_utility.set_location('Entering:'||l_proc, 5);
260 --
261 -- We must now examine each argument value in the
262 -- p_rec plsql record structure
263 -- to see if a system default is being used. If a system default
264 -- is being used then we must set to the 'current' argument value.
265 --
266 If (p_rec.activity_version_id = hr_api.g_number) then
267 p_rec.activity_version_id :=
268 ota_tsp_shd.g_old_rec.activity_version_id;
269 End If;
270 If (p_rec.type = hr_api.g_varchar2) then
271 p_rec.type :=
272 ota_tsp_shd.g_old_rec.type;
273 End If;
274 If (p_rec.comments = hr_api.g_varchar2) then
275 p_rec.comments :=
276 ota_tsp_shd.g_old_rec.comments;
277 End If;
278 If (p_rec.tsp_information_category = hr_api.g_varchar2) then
279 p_rec.tsp_information_category :=
280 ota_tsp_shd.g_old_rec.tsp_information_category;
281 End If;
282 If (p_rec.tsp_information1 = hr_api.g_varchar2) then
283 p_rec.tsp_information1 :=
284 ota_tsp_shd.g_old_rec.tsp_information1;
285 End If;
286 If (p_rec.tsp_information2 = hr_api.g_varchar2) then
287 p_rec.tsp_information2 :=
288 ota_tsp_shd.g_old_rec.tsp_information2;
289 End If;
290 If (p_rec.tsp_information3 = hr_api.g_varchar2) then
291 p_rec.tsp_information3 :=
292 ota_tsp_shd.g_old_rec.tsp_information3;
293 End If;
294 If (p_rec.tsp_information4 = hr_api.g_varchar2) then
295 p_rec.tsp_information4 :=
296 ota_tsp_shd.g_old_rec.tsp_information4;
297 End If;
298 If (p_rec.tsp_information5 = hr_api.g_varchar2) then
299 p_rec.tsp_information5 :=
300 ota_tsp_shd.g_old_rec.tsp_information5;
301 End If;
302 If (p_rec.tsp_information6 = hr_api.g_varchar2) then
303 p_rec.tsp_information6 :=
304 ota_tsp_shd.g_old_rec.tsp_information6;
305 End If;
306 If (p_rec.tsp_information7 = hr_api.g_varchar2) then
307 p_rec.tsp_information7 :=
308 ota_tsp_shd.g_old_rec.tsp_information7;
309 End If;
310 If (p_rec.tsp_information8 = hr_api.g_varchar2) then
311 p_rec.tsp_information8 :=
312 ota_tsp_shd.g_old_rec.tsp_information8;
313 End If;
314 If (p_rec.tsp_information9 = hr_api.g_varchar2) then
315 p_rec.tsp_information9 :=
316 ota_tsp_shd.g_old_rec.tsp_information9;
317 End If;
318 If (p_rec.tsp_information10 = hr_api.g_varchar2) then
319 p_rec.tsp_information10 :=
320 ota_tsp_shd.g_old_rec.tsp_information10;
321 End If;
322 If (p_rec.tsp_information11 = hr_api.g_varchar2) then
323 p_rec.tsp_information11 :=
324 ota_tsp_shd.g_old_rec.tsp_information11;
325 End If;
326 If (p_rec.tsp_information12 = hr_api.g_varchar2) then
327 p_rec.tsp_information12 :=
328 ota_tsp_shd.g_old_rec.tsp_information12;
329 End If;
333 End If;
330 If (p_rec.tsp_information13 = hr_api.g_varchar2) then
331 p_rec.tsp_information13 :=
332 ota_tsp_shd.g_old_rec.tsp_information13;
334 If (p_rec.tsp_information14 = hr_api.g_varchar2) then
335 p_rec.tsp_information14 :=
336 ota_tsp_shd.g_old_rec.tsp_information14;
337 End If;
338 If (p_rec.tsp_information15 = hr_api.g_varchar2) then
339 p_rec.tsp_information15 :=
340 ota_tsp_shd.g_old_rec.tsp_information15;
341 End If;
342 If (p_rec.tsp_information16 = hr_api.g_varchar2) then
343 p_rec.tsp_information16 :=
344 ota_tsp_shd.g_old_rec.tsp_information16;
345 End If;
346 If (p_rec.tsp_information17 = hr_api.g_varchar2) then
347 p_rec.tsp_information17 :=
348 ota_tsp_shd.g_old_rec.tsp_information17;
349 End If;
350 If (p_rec.tsp_information18 = hr_api.g_varchar2) then
351 p_rec.tsp_information18 :=
352 ota_tsp_shd.g_old_rec.tsp_information18;
353 End If;
354 If (p_rec.tsp_information19 = hr_api.g_varchar2) then
355 p_rec.tsp_information19 :=
356 ota_tsp_shd.g_old_rec.tsp_information19;
357 End If;
358 If (p_rec.tsp_information20 = hr_api.g_varchar2) then
359 p_rec.tsp_information20 :=
360 ota_tsp_shd.g_old_rec.tsp_information20;
361 End If;
362 If (p_rec.analysis_criteria_id = hr_api.g_number) then
363 p_rec.analysis_criteria_id :=
364 ota_tsp_shd.g_old_rec.analysis_criteria_id;
365 End If;
366 --
367 -- Return the plsql record structure.
368 --
369 hr_utility.set_location(' Leaving:'||l_proc, 10);
370 Return(p_rec);
371 --
372 End convert_defs;
373 --
374 -- ----------------------------------------------------------------------------
375 -- |---------------------------------< upd >----------------------------------|
376 -- ----------------------------------------------------------------------------
377 Procedure upd
378 (
379 p_rec in out nocopy ota_tsp_shd.g_rec_type,
380 p_validate in boolean default false
381 ) is
382 --
383 l_proc varchar2(72) := g_package||'upd';
384 --
385 Begin
386 hr_utility.set_location('Entering:'||l_proc, 5);
387 --
388 -- Determine if the business process is to be validated.
389 --
390 If p_validate then
391 --
392 -- Issue the savepoint.
393 --
394 SAVEPOINT upd_tsp;
395 End If;
396 --
397 -- We must lock the row which we need to update.
398 --
399 ota_tsp_shd.lck
400 (
401 p_rec.skill_provision_id,
402 p_rec.object_version_number
403 );
404 --
405 -- 1. During an update system defaults are used to determine if
406 -- arguments have been defaulted or not. We must therefore
407 -- derive the full record structure values to be updated.
408 --
409 -- 2. Call the supporting update validate operations.
410 --
411 ota_tsp_bus.update_validate(convert_defs(p_rec));
412 --
413 -- Call the supporting pre-update operation
414 --
415 pre_update(p_rec);
416 --
417 -- Update the row.
418 --
419 update_dml(p_rec);
420 --
421 -- Call the supporting post-update operation
422 --
423 post_update(p_rec);
424 --
425 -- If we are validating then raise the Validate_Enabled exception
426 --
427 If p_validate then
428 Raise HR_Api.Validate_Enabled;
429 End If;
430 --
431 hr_utility.set_location(' Leaving:'||l_proc, 10);
432 Exception
433 When HR_Api.Validate_Enabled Then
434 --
435 -- As the Validate_Enabled exception has been raised
436 -- we must rollback to the savepoint
437 --
438 ROLLBACK TO upd_tsp;
439 End upd;
440 --
441 -- ----------------------------------------------------------------------------
442 -- |---------------------------------< upd >----------------------------------|
443 -- ----------------------------------------------------------------------------
444 Procedure upd
445 (
446 p_skill_provision_id in number,
447 p_activity_version_id in number default hr_api.g_number,
448 p_object_version_number in out nocopy number,
449 p_type in varchar2 default hr_api.g_varchar2,
450 p_comments in varchar2 default hr_api.g_varchar2,
451 p_tsp_information_category in varchar2 default hr_api.g_varchar2,
452 p_tsp_information1 in varchar2 default hr_api.g_varchar2,
453 p_tsp_information2 in varchar2 default hr_api.g_varchar2,
454 p_tsp_information3 in varchar2 default hr_api.g_varchar2,
455 p_tsp_information4 in varchar2 default hr_api.g_varchar2,
456 p_tsp_information5 in varchar2 default hr_api.g_varchar2,
457 p_tsp_information6 in varchar2 default hr_api.g_varchar2,
458 p_tsp_information7 in varchar2 default hr_api.g_varchar2,
459 p_tsp_information8 in varchar2 default hr_api.g_varchar2,
460 p_tsp_information9 in varchar2 default hr_api.g_varchar2,
461 p_tsp_information10 in varchar2 default hr_api.g_varchar2,
462 p_tsp_information11 in varchar2 default hr_api.g_varchar2,
463 p_tsp_information12 in varchar2 default hr_api.g_varchar2,
464 p_tsp_information13 in varchar2 default hr_api.g_varchar2,
465 p_tsp_information14 in varchar2 default hr_api.g_varchar2,
466 p_tsp_information15 in varchar2 default hr_api.g_varchar2,
467 p_tsp_information16 in varchar2 default hr_api.g_varchar2,
468 p_tsp_information17 in varchar2 default hr_api.g_varchar2,
469 p_tsp_information18 in varchar2 default hr_api.g_varchar2,
470 p_tsp_information19 in varchar2 default hr_api.g_varchar2,
471 p_tsp_information20 in varchar2 default hr_api.g_varchar2,
472 p_analysis_criteria_id in number default hr_api.g_number,
473 p_validate in boolean default false
474 ) is
475 --
476 l_rec ota_tsp_shd.g_rec_type;
477 l_proc varchar2(72) := g_package||'upd';
478 --
479 Begin
480 hr_utility.set_location('Entering:'||l_proc, 5);
481 --
482 -- Call conversion function to turn arguments into the
483 -- l_rec structure.
484 --
485 l_rec :=
486 ota_tsp_shd.convert_args
487 (
488 p_skill_provision_id,
489 p_activity_version_id,
490 p_object_version_number,
491 p_type,
492 p_comments,
493 p_tsp_information_category,
494 p_tsp_information1,
495 p_tsp_information2,
496 p_tsp_information3,
497 p_tsp_information4,
498 p_tsp_information5,
499 p_tsp_information6,
500 p_tsp_information7,
501 p_tsp_information8,
502 p_tsp_information9,
503 p_tsp_information10,
504 p_tsp_information11,
505 p_tsp_information12,
506 p_tsp_information13,
507 p_tsp_information14,
508 p_tsp_information15,
509 p_tsp_information16,
510 p_tsp_information17,
511 p_tsp_information18,
512 p_tsp_information19,
513 p_tsp_information20,
514 p_analysis_criteria_id
515 );
516 --
517 -- Having converted the arguments into the
518 -- plsql record structure we call the corresponding record
519 -- business process.
520 --
521 upd(l_rec, p_validate);
522 p_object_version_number := l_rec.object_version_number;
523 --
524 hr_utility.set_location(' Leaving:'||l_proc, 10);
525 End upd;
526 --
527 end ota_tsp_upd;