1 Package Body per_cpl_upd as
2 /* $Header: pecplrhi.pkb 120.0.12000000.2 2007/05/30 12:19:15 arumukhe ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_cpl_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_cpl_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_competences_tl Row
67 --
68 update per_competences_tl
69 set
70 competence_id = p_rec.competence_id
71 ,language = p_rec.language
72 ,source_lang = p_rec.source_lang
73 ,name = p_rec.name
74 ,competence_alias = p_rec.competence_alias
75 ,behavioural_indicator = p_rec.behavioural_indicator
76 ,description = p_rec.description
77 where competence_id = p_rec.competence_id
78 and language = p_rec.language;
79 --
80 --
81 --
82 hr_utility.set_location(' Leaving:'||l_proc, 10);
83 --
84 Exception
85 When hr_api.check_integrity_violated Then
86 -- A check constraint has been violated
87 --
88 per_cpl_shd.constraint_error
89 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
90 When hr_api.parent_integrity_violated Then
91 -- Parent integrity has been violated
92 --
93 per_cpl_shd.constraint_error
94 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
95 When hr_api.unique_integrity_violated Then
96 -- Unique integrity has been violated
97 --
98 per_cpl_shd.constraint_error
99 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
100 When Others Then
101 --
102 Raise;
103 End update_dml;
104 --
105 -- ----------------------------------------------------------------------------
106 -- |------------------------------< pre_update >------------------------------|
107 -- ----------------------------------------------------------------------------
108 -- {Start Of Comments}
109 --
110 -- Description:
111 -- This private procedure contains any processing which is required before
112 -- the update dml.
113 --
114 -- Prerequisites:
115 -- This is an internal procedure which is called from the upd procedure.
116 --
117 -- In Parameters:
118 -- A Pl/Sql record structure.
119 --
120 -- Post Success:
121 -- Processing continues.
122 --
123 -- Post Failure:
124 -- If an error has occurred, an error message and exception wil be raised
125 -- but not handled.
126 --
127 -- Developer Implementation Notes:
128 -- Any pre-processing required before the update dml is issued should be
129 -- coded within this procedure. It is important to note that any 3rd party
130 -- maintenance should be reviewed before placing in this procedure.
131 --
132 -- Access Status:
133 -- Internal Row Handler Use Only.
134 --
135 -- {End Of Comments}
136 -- ----------------------------------------------------------------------------
137 Procedure pre_update
138 (p_rec in per_cpl_shd.g_rec_type
139 ) is
140 --
141 l_proc varchar2(72) := g_package||'pre_update';
142 --
143 Begin
144 hr_utility.set_location('Entering:'||l_proc, 5);
145 --
146 hr_utility.set_location(' Leaving:'||l_proc, 10);
147 End pre_update;
148 --
149 -- ----------------------------------------------------------------------------
150 -- |-----------------------------< post_update >------------------------------|
151 -- ----------------------------------------------------------------------------
152 -- {Start Of Comments}
153 --
154 -- Description:
155 -- This private procedure contains any processing which is required after
156 -- the update dml.
157 --
158 -- Prerequisites:
159 -- This is an internal procedure which is called from the upd procedure.
160 --
161 -- In Parameters:
162 -- A Pl/Sql record structure.
163 --
164 -- Post Success:
165 -- Processing continues.
166 --
167 -- Post Failure:
168 -- If an error has occurred, an error message and exception will be raised
169 -- but not handled.
170 --
171 -- Developer Implementation Notes:
172 -- Any post-processing required after the update dml is issued should be
173 -- coded within this procedure. It is important to note that any 3rd party
174 -- maintenance should be reviewed before placing in this procedure.
175 --
176 -- Access Status:
177 -- Internal Row Handler Use Only.
178 --
179 -- {End Of Comments}
180 -- ----------------------------------------------------------------------------
181 Procedure post_update
182 (p_effective_date in date
183 ,p_rec in per_cpl_shd.g_rec_type
184 ) is
185 --
186 l_proc varchar2(72) := g_package||'post_update';
187 --
188 Begin
189 hr_utility.set_location('Entering:'||l_proc, 5);
190 begin
191 --
192 per_cpl_rku.after_update
193 (p_effective_date => p_effective_date
194 ,p_competence_id
195 => p_rec.competence_id
196 ,p_language
197 => p_rec.language
198 ,p_source_lang
199 => p_rec.source_lang
200 ,p_name
201 => p_rec.name
202 ,p_competence_alias
203 => p_rec.competence_alias
204 ,p_behavioural_indicator
205 => p_rec.behavioural_indicator
206 ,p_description
207 => p_rec.description
208 ,p_source_lang_o
209 => per_cpl_shd.g_old_rec.source_lang
210 ,p_name_o
211 => per_cpl_shd.g_old_rec.name
212 ,p_competence_alias_o
213 => per_cpl_shd.g_old_rec.competence_alias
214 ,p_behavioural_indicator_o
215 => per_cpl_shd.g_old_rec.behavioural_indicator
216 ,p_description_o
217 => per_cpl_shd.g_old_rec.description
218 );
219 --
220 exception
221 --
222 when hr_api.cannot_find_prog_unit then
223 --
224 hr_api.cannot_find_prog_unit_error
225 (p_module_name => 'PER_COMPETENCES_TL'
226 ,p_hook_type => 'AU');
227 --
228 end;
229 --
230 hr_utility.set_location(' Leaving:'||l_proc, 10);
231 End post_update;
232 --
233 -- ----------------------------------------------------------------------------
234 -- |-----------------------------< convert_defs >-----------------------------|
235 -- ----------------------------------------------------------------------------
236 -- {Start Of Comments}
237 --
238 -- Description:
239 -- The Convert_Defs procedure has one very important function:
240 -- It must return the record structure for the row with all system defaulted
241 -- values converted into its corresponding parameter value for update. When
242 -- we attempt to update a row through the Upd process , certain
243 -- parameters can be defaulted which enables flexibility in the calling of
244 -- the upd process (e.g. only attributes which need to be updated need to be
245 -- specified). For the upd process to determine which attributes
246 -- have NOT been specified we need to check if the parameter has a reserved
247 -- system default value. Therefore, for all parameters which have a
248 -- corresponding reserved system default mechanism specified we need to
249 -- check if a system default is being used. If a system default is being
250 -- used then we convert the defaulted value into its corresponding attribute
251 -- value held in the g_old_rec data structure.
252 --
253 -- Prerequisites:
254 -- This private function can only be called from the upd process.
255 --
256 -- In Parameters:
257 -- A Pl/Sql record structure.
258 --
259 -- Post Success:
260 -- The record structure will be returned with all system defaulted parameter
261 -- values converted into its current row attribute value.
262 --
263 -- Post Failure:
264 -- No direct error handling is required within this function. Any possible
265 -- errors within this procedure will be a PL/SQL value error due to
266 -- conversion of datatypes or data lengths.
267 --
268 -- Developer Implementation Notes:
269 -- None.
270 --
271 -- Access Status:
272 -- Internal Row Handler Use Only.
273 --
274 -- {End Of Comments}
275 -- ----------------------------------------------------------------------------
276 Procedure convert_defs
277 (p_rec in out NOCOPY per_cpl_shd.g_rec_type
278 ) is
279 --
280 Begin
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.source_lang = hr_api.g_varchar2) then
288 p_rec.source_lang :=
289 per_cpl_shd.g_old_rec.source_lang;
290 End If;
291 If (p_rec.name = hr_api.g_varchar2) then
292 p_rec.name :=
293 per_cpl_shd.g_old_rec.name;
294 End If;
295 If (p_rec.competence_alias = hr_api.g_varchar2) then
296 p_rec.competence_alias :=
297 per_cpl_shd.g_old_rec.competence_alias;
298 End If;
299 If (p_rec.behavioural_indicator = hr_api.g_varchar2) then
300 p_rec.behavioural_indicator :=
301 per_cpl_shd.g_old_rec.behavioural_indicator;
302 End If;
303 If (p_rec.description = hr_api.g_varchar2) then
304 p_rec.description :=
305 per_cpl_shd.g_old_rec.description;
306 End If;
307 --
308 End convert_defs;
309 --
310 -- ----------------------------------------------------------------------------
311 -- |---------------------------------< upd >----------------------------------|
312 -- ----------------------------------------------------------------------------
313 Procedure upd
314 (p_effective_date in date
315 ,p_rec in out NOCOPY per_cpl_shd.g_rec_type
316 ) is
317 --
318 l_proc varchar2(72) := g_package||'upd';
319 --
320 Begin
321 hr_utility.set_location('Entering:'||l_proc, 5);
322 --
323 -- We must lock the row which we need to update.
324 --
325 per_cpl_shd.lck
326 (p_rec.competence_id
327 ,p_rec.language
328 );
329 --
330 -- 1. During an update system defaults are used to determine if
331 -- arguments have been defaulted or not. We must therefore
332 -- derive the full record structure values to be updated.
333 --
334 -- 2. Call the supporting update validate operations.
335 --
336 convert_defs(p_rec);
337 per_cpl_bus.update_validate
338 (p_effective_date
339 ,p_rec
340 );
341 --
342 -- Call to raise any errors on multi-message list
343 hr_multi_message.end_validation_set;
344 --
345 -- Call the supporting pre-update operation
346 --
347 per_cpl_upd.pre_update(p_rec);
348 --
349 -- Update the row.
350 --
351 per_cpl_upd.update_dml(p_rec);
352 --
353 -- Call the supporting post-update operation
354 --
355 per_cpl_upd.post_update
356 (p_effective_date
357 ,p_rec
358 );
359 --
360 -- Call to raise any errors on multi-message list
361 hr_multi_message.end_validation_set;
362 End upd;
363 --
364 -- ----------------------------------------------------------------------------
365 -- |---------------------------------< upd >----------------------------------|
366 -- ----------------------------------------------------------------------------
367 Procedure upd
368 (p_effective_date in date
369 ,p_competence_id in number
370 ,p_language in varchar2
371 ,p_source_lang in varchar2 default hr_api.g_varchar2
372 ,p_name in varchar2 default hr_api.g_varchar2
373 ,p_competence_alias in varchar2 default hr_api.g_varchar2
374 ,p_behavioural_indicator in varchar2 default hr_api.g_varchar2
375 ,p_description in varchar2 default hr_api.g_varchar2
376 ) is
377 --
378 l_rec per_cpl_shd.g_rec_type;
379 l_proc varchar2(72) := g_package||'upd';
380 --
381 Begin
382 hr_utility.set_location('Entering:'||l_proc, 5);
383 --
384 -- Call conversion function to turn arguments into the
385 -- l_rec structure.
386 --
387 l_rec :=
388 per_cpl_shd.convert_args
389 (p_competence_id
390 ,p_language
391 ,p_source_lang
392 ,p_name
393 ,p_competence_alias
394 ,p_behavioural_indicator
395 ,p_description
396 );
397 --
398 -- Having converted the arguments into the
399 -- plsql record structure we call the corresponding record
400 -- business process.
401 --
402 per_cpl_upd.upd
403 (p_effective_date
404 ,l_rec
405 );
406 --
407 --
408 hr_utility.set_location(' Leaving:'||l_proc, 10);
409 End upd;
410 --
411 -- ----------------------------------------------------------------------------
412 -- |------------------------------< upd_tl >----------------------------------|
413 -- ----------------------------------------------------------------------------
414 Procedure upd_tl
415 (p_effective_date in date
416 ,p_language_code in varchar2
417 ,p_competence_id in number
418 ,p_name in varchar2 default hr_api.g_varchar2
419 ,p_competence_alias in varchar2 default hr_api.g_varchar2
420 ,p_behavioural_indicator in varchar2 default hr_api.g_varchar2
421 ,p_description in varchar2 default hr_api.g_varchar2
422 ) is
423 --
424 -- Cursor to obtain the translation rows where the language or
425 -- source_lang match the specified language.
426 --
427 cursor csr_upd_langs is
428 select cpl.language
429 from per_competences_tl cpl
430 where cpl.competence_id = p_competence_id
431 and p_language_code in (cpl.language
432 ,cpl.source_lang);
433 --
434 l_proc varchar2(72) := g_package||'upd_tl';
435 --
436 Begin
437 hr_utility.set_location('Entering:'||l_proc,10);
438 --
439 -- Update the translated values for every matching row
440 -- setting SOURCE_LANG to the specified language.
441 --
442 for l_lang in csr_upd_langs loop
443 per_cpl_upd.upd
444 (p_effective_date => p_effective_date
445 ,p_competence_id => p_competence_id
446 ,p_language => l_lang.language
447 ,p_source_lang => p_language_code
448 ,p_name => p_name
449 ,p_competence_alias => p_competence_alias
450 ,p_behavioural_indicator => p_behavioural_indicator
451 ,p_description => p_description
452 );
453 end loop;
454 --
455 -- Update the translated values for every matching row
456 --
457 upd_key_flex_meanings( p_competence_id );
458 --
459 hr_utility.set_location(' Leaving:'||l_proc,20);
460 End upd_tl;
461 --
462 -- ----------------------------------------------------------------------------
463 -- |------------------------------< upd_key_flex_meanings >-------------------|
464 -- ----------------------------------------------------------------------------
465 --
466 Procedure upd_key_flex_meanings
467 ( p_competence_id in number
468 )
469 IS
470 --
471 -- Return a cartesian set (we want every installed/base lang)
472 --
473 cursor c_languages IS
474 select l.language_code
475 , l.nls_language
476 , cd.id_flex_num
477 , cd.competence_definition_id
478 from fnd_languages l
479 , per_competences cpn
480 , per_competence_definitions cd
481 where cpn.competence_id = p_competence_id
482 and cpn.competence_definition_id = cd.competence_definition_id
483 and l.installed_flag IN ('B', 'I');
484
485 --
486 l_userenv_language_code VARCHAR2(4) := userenv('LANG'); --Bug 2962837.
487 --
488 l_cpl_rec per_cpl_shd.g_rec_type;
489 --
490 l_proc varchar2(72) := g_package||'upd_key_flex_meanings';
491 --
492 Begin
493 --
494 hr_utility.set_location('Entering:'||l_proc, 5);
495 --
496 For l_language IN c_languages Loop
497 --
498 -- Lock the existing record (which may already be updated)
499 --
500 per_cpl_shd.lck( p_competence_id => p_competence_id
501 , p_language => l_language.language_code);
502 --
503 -- Get the local record values from the locked record
504 --
505 l_cpl_rec := per_cpl_shd.g_old_rec;
506
507 --
508 -- Set the session language
509 --
510 hr_kflex_utility.set_session_nls_language( l_language.nls_language );
511
512 --
513 --Populate the local record with translated key flex meanings
514 --
515 -- Start of bug#2925181
516 -- added nvl check for bug # 6039259
517 l_cpl_rec.name := nvl(substr(fnd_flex_ext.get_segs( per_cpl_shd.g_app_code
518 , per_cpl_shd.g_flex_code
519 , l_language.id_flex_num
520 , l_language.competence_definition_id),1,700),l_cpl_rec.name);
521
522
523 -- End of bug#2925181
524 --Update the record
525 --
526 update_dml(l_cpl_rec);
527 --
528 End Loop;
529 --
530 -- Set the session language
531 --
532 hr_kflex_utility.set_session_language_code( l_userenv_language_code );
533 --
534 hr_utility.set_location(' Leaving:'||l_proc,20);
535 --
536 Exception
537 --
538 When Others Then
539 --
540 -- Set the session language
541 --
542
543 hr_kflex_utility.set_session_language_code( l_userenv_language_code );
544 --
545 raise;
546 --
547 End upd_key_flex_meanings;
548 --
549 end per_cpl_upd;