1 Package Body per_qat_upd as
2 /* $Header: peqatrhi.pkb 120.0.12010000.2 2008/11/20 12:27:31 kgowripe ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_qat_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 per_qat_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 --
64 --
65 --
66 -- Update the per_qualifications_tl Row
67 --
68 update per_qualifications_tl
69 set
70 qualification_id = p_rec.qualification_id
71 ,language = p_rec.language
72 ,source_lang = p_rec.source_lang
73 ,title = p_rec.title
74 ,group_ranking = p_rec.group_ranking
75 ,license_restrictions = p_rec.license_restrictions
76 ,awarding_body = p_rec.awarding_body
77 ,grade_attained = p_rec.grade_attained
78 ,reimbursement_arrangements = p_rec.reimbursement_arrangements
79 ,training_completed_units = p_rec.training_completed_units
80 ,membership_category = p_rec.membership_category
81 where qualification_id = p_rec.qualification_id
82 and language = p_rec.language;
83 --
84 --
85 --
86 hr_utility.set_location(' Leaving:'||l_proc, 10);
87 --
88 Exception
89 When hr_api.check_integrity_violated Then
90 -- A check constraint has been violated
91 --
92 per_qat_shd.constraint_error
93 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
94 When hr_api.parent_integrity_violated Then
95 -- Parent integrity has been violated
96 --
97 per_qat_shd.constraint_error
98 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
99 When hr_api.unique_integrity_violated Then
100 -- Unique integrity has been violated
101 --
102 per_qat_shd.constraint_error
103 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
104 When Others Then
105 --
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 structure.
123 --
124 -- Post Success:
125 -- Processing continues.
126 --
127 -- Post Failure:
128 -- If an error has occurred, an error message and exception wil 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
142 (p_rec in per_qat_shd.g_rec_type
143 ) is
144 --
145 l_proc varchar2(72) := g_package||'pre_update';
146 --
147 Begin
148 hr_utility.set_location('Entering:'||l_proc, 5);
149 --
150 hr_utility.set_location(' Leaving:'||l_proc, 10);
151 End pre_update;
152 --
153 -- ----------------------------------------------------------------------------
154 -- |-----------------------------< post_update >------------------------------|
155 -- ----------------------------------------------------------------------------
156 -- {Start Of Comments}
157 --
158 -- Description:
159 -- This private procedure contains any processing which is required after
160 -- the update dml.
161 --
162 -- Prerequisites:
163 -- This is an internal procedure which is called from the upd procedure.
164 --
165 -- In Parameters:
166 -- A Pl/Sql record structure.
167 --
168 -- Post Success:
169 -- Processing continues.
170 --
171 -- Post Failure:
172 -- If an error has occurred, an error message and exception will be raised
173 -- but not handled.
174 --
175 -- Developer Implementation Notes:
176 -- Any post-processing required after the update dml is issued should be
177 -- coded within this procedure. It is important to note that any 3rd party
178 -- maintenance should be reviewed before placing in this procedure.
179 --
180 -- Access Status:
181 -- Internal Row Handler Use Only.
182 --
183 -- {End Of Comments}
184 -- ----------------------------------------------------------------------------
185 Procedure post_update
186 (p_rec in per_qat_shd.g_rec_type
187 ) is
188 --
189 l_proc varchar2(72) := g_package||'post_update';
190 --
191 Begin
192 hr_utility.set_location('Entering:'||l_proc, 5);
193 begin
194 --
195 per_qat_rku.after_update
196 (p_qualification_id
197 => p_rec.qualification_id
198 ,p_language
199 => p_rec.language
200 ,p_source_lang
201 => p_rec.source_lang
202 ,p_title
203 => p_rec.title
204 ,p_group_ranking
205 => p_rec.group_ranking
206 ,p_license_restrictions
207 => p_rec.license_restrictions
208 ,p_awarding_body
209 => p_rec.awarding_body
210 ,p_grade_attained
211 => p_rec.grade_attained
212 ,p_reimbursement_arrangements
213 => p_rec.reimbursement_arrangements
214 ,p_training_completed_units
215 => p_rec.training_completed_units
216 ,p_membership_category
217 => p_rec.membership_category
218 ,p_source_lang_o
219 => per_qat_shd.g_old_rec.source_lang
220 ,p_title_o
221 => per_qat_shd.g_old_rec.title
222 ,p_group_ranking_o
223 => per_qat_shd.g_old_rec.group_ranking
224 ,p_license_restrictions_o
225 => per_qat_shd.g_old_rec.license_restrictions
226 ,p_awarding_body_o
227 => per_qat_shd.g_old_rec.awarding_body
228 ,p_grade_attained_o
229 => per_qat_shd.g_old_rec.grade_attained
230 ,p_reimbursement_arrangements_o
231 => per_qat_shd.g_old_rec.reimbursement_arrangements
232 ,p_training_completed_units_o
233 => per_qat_shd.g_old_rec.training_completed_units
234 ,p_membership_category_o
235 => per_qat_shd.g_old_rec.membership_category
236 );
237 --
238 exception
239 --
240 when hr_api.cannot_find_prog_unit then
241 --
242 hr_api.cannot_find_prog_unit_error
243 (p_module_name => 'PER_QUALIFICATIONS_TL'
244 ,p_hook_type => 'AU');
245 --
246 end;
247 --
248 hr_utility.set_location(' Leaving:'||l_proc, 10);
249 End post_update;
250 --
251 -- ----------------------------------------------------------------------------
252 -- |-----------------------------< convert_defs >-----------------------------|
253 -- ----------------------------------------------------------------------------
254 -- {Start Of Comments}
255 --
256 -- Description:
257 -- The Convert_Defs procedure has one very important function:
258 -- It must return the record structure for the row with all system defaulted
259 -- values converted into its corresponding parameter value for update. When
260 -- we attempt to update a row through the Upd process , certain
261 -- parameters can be defaulted which enables flexibility in the calling of
262 -- the upd process (e.g. only attributes which need to be updated need to be
263 -- specified). For the upd process to determine which attributes
264 -- have NOT been specified we need to check if the parameter has a reserved
265 -- system default value. Therefore, for all parameters which have a
266 -- corresponding reserved system default mechanism specified we need to
267 -- check if a system default is being used. If a system default is being
268 -- used then we convert the defaulted value into its corresponding attribute
269 -- value held in the g_old_rec data structure.
270 --
271 -- Prerequisites:
272 -- This private function can only be called from the upd process.
273 --
274 -- In Parameters:
275 -- A Pl/Sql record structure.
276 --
277 -- Post Success:
278 -- The record structure will be returned with all system defaulted parameter
279 -- values converted into its current row attribute value.
280 --
281 -- Post Failure:
282 -- No direct error handling is required within this function. Any possible
283 -- errors within this procedure will be a PL/SQL value error due to
284 -- conversion of datatypes or data lengths.
285 --
286 -- Developer Implementation Notes:
287 -- None.
288 --
289 -- Access Status:
290 -- Internal Row Handler Use Only.
291 --
292 -- {End Of Comments}
293 -- ----------------------------------------------------------------------------
294 Procedure convert_defs
295 (p_rec in out nocopy per_qat_shd.g_rec_type
296 ) is
297 --
298 Begin
299 --
300 -- We must now examine each argument value in the
301 -- p_rec plsql record structure
302 -- to see if a system default is being used. If a system default
303 -- is being used then we must set to the 'current' argument value.
304 --
305 If (p_rec.source_lang = hr_api.g_varchar2) then
306 p_rec.source_lang :=
307 per_qat_shd.g_old_rec.source_lang;
308 End If;
309 If (p_rec.title = hr_api.g_varchar2) then
310 p_rec.title :=
311 per_qat_shd.g_old_rec.title;
312 End If;
313 If (p_rec.group_ranking = hr_api.g_varchar2) then
314 p_rec.group_ranking :=
315 per_qat_shd.g_old_rec.group_ranking;
316 End If;
317 If (p_rec.license_restrictions = hr_api.g_varchar2) then
318 p_rec.license_restrictions :=
319 per_qat_shd.g_old_rec.license_restrictions;
320 End If;
321 If (p_rec.awarding_body = hr_api.g_varchar2) then
322 p_rec.awarding_body :=
323 per_qat_shd.g_old_rec.awarding_body;
324 End If;
325 If (p_rec.grade_attained = hr_api.g_varchar2) then
326 p_rec.grade_attained :=
327 per_qat_shd.g_old_rec.grade_attained;
328 End If;
329 If (p_rec.reimbursement_arrangements = hr_api.g_varchar2) then
330 p_rec.reimbursement_arrangements :=
331 per_qat_shd.g_old_rec.reimbursement_arrangements;
332 End If;
333 If (p_rec.training_completed_units = hr_api.g_varchar2) then
334 p_rec.training_completed_units :=
335 per_qat_shd.g_old_rec.training_completed_units;
336 End If;
337 If (p_rec.membership_category = hr_api.g_varchar2) then
338 p_rec.membership_category :=
339 per_qat_shd.g_old_rec.membership_category;
340 End If;
341 --
342 End convert_defs;
343 --
344 -- ----------------------------------------------------------------------------
345 -- |---------------------------------< upd >----------------------------------|
346 -- ----------------------------------------------------------------------------
347 Procedure upd
348 (p_rec in out nocopy per_qat_shd.g_rec_type
349 ) is
350 --
351 l_proc varchar2(72) := g_package||'upd';
352 --
353 Begin
354 hr_utility.set_location('Entering:'||l_proc, 5);
355 --
356 -- We must lock the row which we need to update.
357 --
358 per_qat_shd.lck
359 (p_rec.qualification_id
360 ,p_rec.language
361 );
362 --
363 -- 1. During an update system defaults are used to determine if
364 -- arguments have been defaulted or not. We must therefore
365 -- derive the full record structure values to be updated.
366 --
367 -- 2. Call the supporting update validate operations.
368 --
369 convert_defs(p_rec);
370 per_qat_bus.update_validate
371 (p_rec
372 );
373 --
374 -- Call to raise any errors on multi-message list
375 hr_multi_message.end_validation_set;
376 --
377 -- Call the supporting pre-update operation
378 --
379 per_qat_upd.pre_update(p_rec);
380 --
381 -- Update the row.
382 --
383 per_qat_upd.update_dml(p_rec);
384 --
385 -- Call the supporting post-update operation
386 --
387 per_qat_upd.post_update
388 (p_rec
389 );
390 --
391 -- Call to raise any errors on multi-message list
392 hr_multi_message.end_validation_set;
393 End upd;
394 --
395 -- ----------------------------------------------------------------------------
396 -- |---------------------------------< upd >----------------------------------|
397 -- ----------------------------------------------------------------------------
398 Procedure upd
399 (p_qualification_id in number
400 ,p_language in varchar2
401 ,p_source_lang in varchar2 default hr_api.g_varchar2
402 ,p_title in varchar2 default hr_api.g_varchar2
403 ,p_group_ranking in varchar2 default hr_api.g_varchar2
404 ,p_license_restrictions in varchar2 default hr_api.g_varchar2
405 ,p_awarding_body in varchar2 default hr_api.g_varchar2
406 ,p_grade_attained in varchar2 default hr_api.g_varchar2
407 ,p_reimbursement_arrangements in varchar2 default hr_api.g_varchar2
408 ,p_training_completed_units in varchar2 default hr_api.g_varchar2
409 ,p_membership_category in varchar2 default hr_api.g_varchar2
410 ) is
411 --
412 l_rec per_qat_shd.g_rec_type;
413 l_proc varchar2(72) := g_package||'upd';
414 --
415 Begin
416 hr_utility.set_location('Entering:'||l_proc, 5);
417 --
418 -- Call conversion function to turn arguments into the
419 -- l_rec structure.
420 --
421 l_rec :=
422 per_qat_shd.convert_args
423 (p_qualification_id
424 ,p_language
425 ,p_source_lang
426 ,p_title
427 ,p_group_ranking
428 ,p_license_restrictions
429 ,p_awarding_body
430 ,p_grade_attained
431 ,p_reimbursement_arrangements
432 ,p_training_completed_units
433 ,p_membership_category
434 );
435 --
436 -- Having converted the arguments into the
437 -- plsql record structure we call the corresponding record
438 -- business process.
439 --
440 per_qat_upd.upd
441 (l_rec
442 );
443 --
444 --
445 hr_utility.set_location(' Leaving:'||l_proc, 10);
446 End upd;
447 --
448 -- ----------------------------------------------------------------------------
449 -- |------------------------------< upd_tl >----------------------------------|
450 -- ----------------------------------------------------------------------------
451 Procedure upd_tl
452 (p_language_code in varchar2
453 ,p_qualification_id in number
454 ,p_title in varchar2 default hr_api.g_varchar2
455 ,p_group_ranking in varchar2 default hr_api.g_varchar2
456 ,p_license_restrictions in varchar2 default hr_api.g_varchar2
457 ,p_awarding_body in varchar2 default hr_api.g_varchar2
458 ,p_grade_attained in varchar2 default hr_api.g_varchar2
459 ,p_reimbursement_arrangements in varchar2 default hr_api.g_varchar2
460 ,p_training_completed_units in varchar2 default hr_api.g_varchar2
461 ,p_membership_category in varchar2 default hr_api.g_varchar2
462 ) is
463 --
464 -- Cursor to obtain the translation rows where the language or
465 -- source_lang match the specified language.
466 --
467 cursor csr_upd_langs is
468 select qat.language
469 from per_qualifications_tl qat
470 where qat.qualification_id = p_qualification_id
471 and p_language_code in (qat.language
472 ,qat.source_lang);
473 --
474 l_proc varchar2(72) := g_package||'upd_tl';
475 --
476 Begin
477 hr_utility.set_location('Entering:'||l_proc,10);
478 --
479 -- Update the translated values for every matching row
480 -- setting SOURCE_LANG to the specified language.
481 --
482 for l_lang in csr_upd_langs loop
483 per_qat_upd.upd
484 (p_qualification_id => p_qualification_id
485 ,p_language => l_lang.language
486 ,p_source_lang => p_language_code
487 ,p_title => p_title
488 ,p_group_ranking => p_group_ranking
489 ,p_license_restrictions => p_license_restrictions
490 ,p_awarding_body => p_awarding_body
491 ,p_grade_attained => p_grade_attained
492 ,p_reimbursement_arrangements => p_reimbursement_arrangements
493 ,p_training_completed_units => p_training_completed_units
494 ,p_membership_category => p_membership_category
495 );
496 end loop;
497 --
498 hr_utility.set_location(' Leaving:'||l_proc,20);
499 End upd_tl;
500 --
501 end per_qat_upd;