1 Package Body per_za_eqt_upd as
2 /* $Header: pezaequp.pkb 115.3 2002/12/05 06:36:07 nsugavan noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_za_eqt_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 -- Pre Conditions:
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 Table Handler Use Only.
51 --
52 -- {End Of Comments}
53 -- ----------------------------------------------------------------------------
54 Procedure update_dml(p_rec in out nocopy per_za_eqt_shd.g_rec_type) is
55 --
56 l_proc varchar2(72) := g_package||'update_dml';
57 l_dummy number;
58 --
59 Begin
60 hr_utility.set_location('Entering:'||l_proc, 5);
61 --
62 -- Increment the object version
63 --
64 p_rec.object_version_number := p_rec.object_version_number + 1;
65 --
66 per_za_eqt_shd.g_api_dml := true; -- Set the api dml status
67 --
68 -- Update the per_qualification_types Row
69 --
70 update per_qualification_types
71 set
72 qualification_type_id = p_rec.qualification_type_id,
73 name = p_rec.name,
74 category = p_rec.category,
75 rank = p_rec.rank,
76 attribute_category = p_rec.attribute_category,
77 attribute1 = p_rec.attribute1,
78 attribute2 = p_rec.attribute2,
79 attribute3 = p_rec.attribute3,
80 attribute4 = p_rec.attribute4,
81 attribute5 = p_rec.attribute5,
82 attribute6 = p_rec.attribute6,
83 attribute7 = p_rec.attribute7,
84 attribute8 = p_rec.attribute8,
85 attribute9 = p_rec.attribute9,
86 attribute10 = p_rec.attribute10,
87 attribute11 = p_rec.attribute11,
88 attribute12 = p_rec.attribute12,
89 attribute13 = p_rec.attribute13,
90 attribute14 = p_rec.attribute14,
91 attribute15 = p_rec.attribute15,
92 attribute16 = p_rec.attribute16,
93 attribute17 = p_rec.attribute17,
94 attribute18 = p_rec.attribute18,
95 attribute19 = p_rec.attribute19,
96 attribute20 = p_rec.attribute20,
97 object_version_number = p_rec.object_version_number
98 where qualification_type_id = p_rec.qualification_type_id;
99
100 begin
101 select 1
102 into l_dummy
103 from per_za_qualification_types
104 where qualification_type_id = p_rec.qualification_type_id;
105
106 -- Record exists, can update.
107 update per_za_qualification_types
108 set nqf_qualification_type = p_rec.nqf_qualification_type
109 where qualification_type_id = p_rec.qualification_type_id;
110
111 exception
112 -- Record does not exists, must insert.
113 when no_data_found then
114 insert into per_za_qualification_types(qualification_type_id,
115 nqf_qualification_type)
116 values(p_rec.qualification_type_id,
117 p_rec.nqf_qualification_type);
118 end;
119
120 --
121 per_za_eqt_shd.g_api_dml := false; -- Unset the api dml status
122 --
123 hr_utility.set_location(' Leaving:'||l_proc, 10);
124 --
125 Exception
126 When hr_api.check_integrity_violated Then
127 -- A check constraint has been violated
128 per_za_eqt_shd.g_api_dml := false; -- Unset the api dml status
129 per_za_eqt_shd.constraint_error
130 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
131 When hr_api.parent_integrity_violated Then
132 -- Parent integrity has been violated
133 per_za_eqt_shd.g_api_dml := false; -- Unset the api dml status
134 per_za_eqt_shd.constraint_error
135 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
136 When hr_api.unique_integrity_violated Then
137 -- Unique integrity has been violated
138 per_za_eqt_shd.g_api_dml := false; -- Unset the api dml status
139 per_za_eqt_shd.constraint_error
140 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
141 When Others Then
142 per_za_eqt_shd.g_api_dml := false; -- Unset the api dml status
143 Raise;
144 End update_dml;
145 --
146 -- ----------------------------------------------------------------------------
147 -- |------------------------------< pre_update >------------------------------|
148 -- ----------------------------------------------------------------------------
149 -- {Start Of Comments}
150 --
151 -- Description:
152 -- This private procedure contains any processing which is required before
153 -- the update dml.
154 --
155 -- Pre Conditions:
156 -- This is an internal procedure which is called from the upd procedure.
157 --
158 -- In Parameters:
159 -- A Pl/Sql record structre.
160 --
161 -- Post Success:
162 -- Processing continues.
163 --
164 -- Post Failure:
165 -- If an error has occurred, an error message and exception will be raised
166 -- but not handled.
167 --
168 -- Developer Implementation Notes:
169 -- Any pre-processing required before the update dml is issued should be
170 -- coded within this procedure. It is important to note that any 3rd party
171 -- maintenance should be reviewed before placing in this procedure.
172 --
173 -- Access Status:
174 -- Internal Table Handler Use Only.
175 --
176 -- {End Of Comments}
177 -- ----------------------------------------------------------------------------
178 Procedure pre_update(p_rec in per_za_eqt_shd.g_rec_type) is
179 --
180 l_proc varchar2(72) := g_package||'pre_update';
181 --
182 Begin
183 hr_utility.set_location('Entering:'||l_proc, 5);
184 --
185 hr_utility.set_location(' Leaving:'||l_proc, 10);
186 End pre_update;
187 --
188 -- ----------------------------------------------------------------------------
189 -- |-----------------------------< post_update >------------------------------|
190 -- ----------------------------------------------------------------------------
191 -- {Start Of Comments}
192 --
193 -- Description:
194 -- This private procedure contains any processing which is required after the
195 -- update dml.
196 --
197 -- Pre Conditions:
198 -- This is an internal procedure which is called from the upd procedure.
199 --
200 -- In Parameters:
201 -- A Pl/Sql record structre.
202 --
203 -- Post Success:
204 -- Processing continues.
205 --
206 -- Post Failure:
207 -- If an error has occurred, an error message and exception will be raised
208 -- but not handled.
209 --
210 -- Developer Implementation Notes:
211 -- Any post-processing required after the update dml is issued should be
212 -- coded within this procedure. It is important to note that any 3rd party
213 -- maintenance should be reviewed before placing in this procedure.
214 --
215 -- Access Status:
216 -- Internal Table Handler Use Only.
217 --
218 -- {End Of Comments}
219 -- ----------------------------------------------------------------------------
220 Procedure post_update(p_rec in per_za_eqt_shd.g_rec_type) is
221 --
222 l_proc varchar2(72) := g_package||'post_update';
223 --
224 Begin
225 hr_utility.set_location('Entering:'||l_proc, 5);
226 --
227 hr_utility.set_location(' Leaving:'||l_proc, 10);
228 End post_update;
229 --
230 -- ----------------------------------------------------------------------------
231 -- |-----------------------------< convert_defs >-----------------------------|
232 -- ----------------------------------------------------------------------------
233 -- {Start Of Comments}
234 --
235 -- Description:
236 -- The Convert_Defs procedure has one very important function:
237 -- It must return the record structure for the row with all system defaulted
238 -- values converted into its corresponding parameter value for update. When
239 -- we attempt to update a row through the Upd process , certain
240 -- parameters can be defaulted which enables flexibility in the calling of
241 -- the upd process (e.g. only attributes which need to be updated need to be
242 -- specified). For the upd process to determine which attributes
243 -- have NOT been specified we need to check if the parameter has a reserved
244 -- system default value. Therefore, for all parameters which have a
245 -- corresponding reserved system default mechanism specified we need to
246 -- check if a system default is being used. If a system default is being
247 -- used then we convert the defaulted value into its corresponding attribute
248 -- value held in the g_old_rec data structure.
249 --
250 -- Pre Conditions:
251 -- This private function can only be called from the upd process.
252 --
253 -- In Parameters:
254 -- A Pl/Sql record structre.
255 --
256 -- Post Success:
257 -- The record structure will be returned with all system defaulted parameter
258 -- values converted into its current row attribute value.
259 --
260 -- Post Failure:
261 -- No direct error handling is required within this function. Any possible
262 -- errors within this procedure will be a PL/SQL value error due to conversion
263
264 -- of datatypes or data lengths.
265 --
266 -- Developer Implementation Notes:
267 -- None.
268 --
269 -- Access Status:
270 -- Internal Table Handler Use Only.
271 --
272 -- {End Of Comments}
273 -- ----------------------------------------------------------------------------
274 Procedure convert_defs(p_rec in out nocopy per_za_eqt_shd.g_rec_type) is
275 --
276 l_proc varchar2(72) := g_package||'convert_defs';
277 --
278 Begin
279 --
280 hr_utility.set_location('Entering:'||l_proc, 5);
281 --
282 -- We must now examine each argument value in the
283 -- p_rec plsql record structure
284 -- to see if a system default is being used. If a system default
285 -- is being used then we must set to the 'current' argument value.
286 --
287 If (p_rec.name = hr_api.g_varchar2) then
288 p_rec.name :=
289 per_za_eqt_shd.g_old_rec.name;
290 End If;
291 If (p_rec.nqf_qualification_type = hr_api.g_varchar2) then
292 p_rec.nqf_qualification_type :=
293 per_za_eqt_shd.g_old_rec.nqf_qualification_type;
294 End If;
295 If (p_rec.category = hr_api.g_varchar2) then
296 p_rec.category :=
297 per_za_eqt_shd.g_old_rec.category;
298 End If;
299 If (p_rec.rank = hr_api.g_number) then
300 p_rec.rank :=
301 per_za_eqt_shd.g_old_rec.rank;
302 End If;
303 If (p_rec.attribute_category = hr_api.g_varchar2) then
304 p_rec.attribute_category :=
305 per_za_eqt_shd.g_old_rec.attribute_category;
306 End If;
307 If (p_rec.attribute1 = hr_api.g_varchar2) then
308 p_rec.attribute1 :=
309 per_za_eqt_shd.g_old_rec.attribute1;
310 End If;
311 If (p_rec.attribute2 = hr_api.g_varchar2) then
312 p_rec.attribute2 :=
313 per_za_eqt_shd.g_old_rec.attribute2;
314 End If;
315 If (p_rec.attribute3 = hr_api.g_varchar2) then
316 p_rec.attribute3 :=
317 per_za_eqt_shd.g_old_rec.attribute3;
318 End If;
319 If (p_rec.attribute4 = hr_api.g_varchar2) then
320 p_rec.attribute4 :=
321 per_za_eqt_shd.g_old_rec.attribute4;
322 End If;
323 If (p_rec.attribute5 = hr_api.g_varchar2) then
324 p_rec.attribute5 :=
325 per_za_eqt_shd.g_old_rec.attribute5;
326 End If;
327 If (p_rec.attribute6 = hr_api.g_varchar2) then
328 p_rec.attribute6 :=
329 per_za_eqt_shd.g_old_rec.attribute6;
330 End If;
331 If (p_rec.attribute7 = hr_api.g_varchar2) then
332 p_rec.attribute7 :=
333 per_za_eqt_shd.g_old_rec.attribute7;
334 End If;
335 If (p_rec.attribute8 = hr_api.g_varchar2) then
336 p_rec.attribute8 :=
337 per_za_eqt_shd.g_old_rec.attribute8;
338 End If;
339 If (p_rec.attribute9 = hr_api.g_varchar2) then
340 p_rec.attribute9 :=
341 per_za_eqt_shd.g_old_rec.attribute9;
342 End If;
343 If (p_rec.attribute10 = hr_api.g_varchar2) then
344 p_rec.attribute10 :=
345 per_za_eqt_shd.g_old_rec.attribute10;
346 End If;
347 If (p_rec.attribute11 = hr_api.g_varchar2) then
348 p_rec.attribute11 :=
349 per_za_eqt_shd.g_old_rec.attribute11;
350 End If;
351 If (p_rec.attribute12 = hr_api.g_varchar2) then
352 p_rec.attribute12 :=
353 per_za_eqt_shd.g_old_rec.attribute12;
354 End If;
355 If (p_rec.attribute13 = hr_api.g_varchar2) then
356 p_rec.attribute13 :=
357 per_za_eqt_shd.g_old_rec.attribute13;
358 End If;
359 If (p_rec.attribute14 = hr_api.g_varchar2) then
360 p_rec.attribute14 :=
361 per_za_eqt_shd.g_old_rec.attribute14;
362 End If;
363 If (p_rec.attribute15 = hr_api.g_varchar2) then
364 p_rec.attribute15 :=
365 per_za_eqt_shd.g_old_rec.attribute15;
366 End If;
367 If (p_rec.attribute16 = hr_api.g_varchar2) then
368 p_rec.attribute16 :=
369 per_za_eqt_shd.g_old_rec.attribute16;
370 End If;
371 If (p_rec.attribute17 = hr_api.g_varchar2) then
372 p_rec.attribute17 :=
373 per_za_eqt_shd.g_old_rec.attribute17;
374 End If;
375 If (p_rec.attribute18 = hr_api.g_varchar2) then
376 p_rec.attribute18 :=
377 per_za_eqt_shd.g_old_rec.attribute18;
378 End If;
379 If (p_rec.attribute19 = hr_api.g_varchar2) then
380 p_rec.attribute19 :=
381 per_za_eqt_shd.g_old_rec.attribute19;
382 End If;
383 If (p_rec.attribute20 = hr_api.g_varchar2) then
384 p_rec.attribute20 :=
385 per_za_eqt_shd.g_old_rec.attribute20;
386 End If;
387
388 --
389 hr_utility.set_location(' Leaving:'||l_proc, 10);
390 --
391 End convert_defs;
392 --
393 -- ----------------------------------------------------------------------------
394 -- |---------------------------------< upd >----------------------------------|
395 -- ----------------------------------------------------------------------------
396 Procedure upd
397 (
398 p_rec in out nocopy per_za_eqt_shd.g_rec_type,
399 p_effective_date in date,
400 p_validate in boolean default false
401 ) is
402 --
403 l_proc varchar2(72) := g_package||'upd';
404 --
405 Begin
406 hr_utility.set_location('Entering:'||l_proc, 5);
407 --
408 -- Determine if the business process is to be validated.
409 --
410 If p_validate then
411 --
412 -- Issue the savepoint.
413 --
414 SAVEPOINT upd_per_za_eqt;
415 End If;
416 --
417 -- We must lock the row which we need to update.
418 --
419 per_za_eqt_shd.lck
420 (
421 p_rec.qualification_type_id,
422 p_rec.object_version_number
423 );
424 --
425 -- 1. During an update system defaults are used to determine if
426 -- arguments have been defaulted or not. We must therefore
427 -- derive the full record structure values to be updated.
428 --
429 -- 2. Call the supporting update validate operations.
430 --
431 convert_defs(p_rec);
432 per_za_eqt_bus.update_validate(p_rec,p_effective_date);
433 --
434 -- Call the supporting pre-update operation
435 --
436 pre_update(p_rec);
437 --
438 -- Update the row.
439 --
440 update_dml(p_rec);
441 --
442 -- Call the supporting post-update operation
443 --
444 post_update(p_rec);
445 --
446 -- If we are validating then raise the Validate_Enabled exception
447 --
448 If p_validate then
449 Raise HR_Api.Validate_Enabled;
450 End If;
451 --
452 hr_utility.set_location(' Leaving:'||l_proc, 10);
453 Exception
454 When HR_Api.Validate_Enabled Then
455 --
456 -- As the Validate_Enabled exception has been raised
457 -- we must rollback to the savepoint
458 --
459 ROLLBACK TO upd_per_za_eqt;
460 End upd;
461 --
462 -- ----------------------------------------------------------------------------
463 -- |---------------------------------< upd >----------------------------------|
464 -- ----------------------------------------------------------------------------
465 Procedure upd
466 (
467 p_qualification_type_id in number,
468 p_nqf_qualification_type in varchar2 default hr_api.g_varchar2,
469 p_name in varchar2 default hr_api.g_varchar2,
470 p_category in varchar2 default hr_api.g_varchar2,
471 p_rank in number default hr_api.g_number,
472 p_attribute_category in varchar2 default hr_api.g_varchar2,
473 p_attribute1 in varchar2 default hr_api.g_varchar2,
474 p_attribute2 in varchar2 default hr_api.g_varchar2,
475 p_attribute3 in varchar2 default hr_api.g_varchar2,
476 p_attribute4 in varchar2 default hr_api.g_varchar2,
477 p_attribute5 in varchar2 default hr_api.g_varchar2,
478 p_attribute6 in varchar2 default hr_api.g_varchar2,
479 p_attribute7 in varchar2 default hr_api.g_varchar2,
480 p_attribute8 in varchar2 default hr_api.g_varchar2,
481 p_attribute9 in varchar2 default hr_api.g_varchar2,
482 p_attribute10 in varchar2 default hr_api.g_varchar2,
483 p_attribute11 in varchar2 default hr_api.g_varchar2,
484 p_attribute12 in varchar2 default hr_api.g_varchar2,
485 p_attribute13 in varchar2 default hr_api.g_varchar2,
486 p_attribute14 in varchar2 default hr_api.g_varchar2,
487 p_attribute15 in varchar2 default hr_api.g_varchar2,
488 p_attribute16 in varchar2 default hr_api.g_varchar2,
489 p_attribute17 in varchar2 default hr_api.g_varchar2,
490 p_attribute18 in varchar2 default hr_api.g_varchar2,
491 p_attribute19 in varchar2 default hr_api.g_varchar2,
492 p_attribute20 in varchar2 default hr_api.g_varchar2,
493 p_object_version_number in out nocopy number,
494 p_effective_date in date,
495 p_validate in boolean default false
496 ) is
497 --
498 l_rec per_za_eqt_shd.g_rec_type;
499 l_proc varchar2(72) := g_package||'upd';
500 --
501 Begin
502 hr_utility.set_location('Entering:'||l_proc, 5);
503 --
504 -- Call conversion function to turn arguments into the
505 -- l_rec structure.
506 --
507 l_rec :=
508 per_za_eqt_shd.convert_args
509 (
510 p_qualification_type_id,
511 p_nqf_qualification_type,
512 p_name,
513 p_category,
514 p_rank,
515 p_attribute_category,
516 p_attribute1,
517 p_attribute2,
518 p_attribute3,
519 p_attribute4,
520 p_attribute5,
521 p_attribute6,
522 p_attribute7,
523 p_attribute8,
524 p_attribute9,
525 p_attribute10,
526 p_attribute11,
527 p_attribute12,
528 p_attribute13,
529 p_attribute14,
530 p_attribute15,
531 p_attribute16,
532 p_attribute17,
533 p_attribute18,
534 p_attribute19,
535 p_attribute20,
536 p_object_version_number
537 );
538 --
539 -- Having converted the arguments into the
540 -- plsql record structure we call the corresponding record
541 -- business process.
542 --
543 upd(l_rec, p_effective_date, p_validate);
544 p_object_version_number := l_rec.object_version_number;
545 --
546 hr_utility.set_location(' Leaving:'||l_proc, 10);
547 End upd;
548 --
549 end per_za_eqt_upd;