1 Package Body ota_ctl_upd as
2 /* $Header: otctlrhi.pkb 120.2 2005/12/01 16:42 cmora noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ota_ctl_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_ctl_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 ota_certifications_tl Row
67 --
68 update ota_certifications_tl
69 set
70 certification_id = p_rec.certification_id
71 ,language = p_rec.language
72 ,name = p_rec.name
73 ,description = p_rec.description
74 ,objectives = p_rec.objectives
75 ,purpose = p_rec.purpose
76 ,keywords = p_rec.keywords
77 ,end_date_comments = p_rec.end_date_comments
78 ,initial_period_comments = p_rec.initial_period_comments
79 ,renewal_period_comments = p_rec.renewal_period_comments
80 ,source_lang = p_rec.source_lang
81 where certification_id = p_rec.certification_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 ota_ctl_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 ota_ctl_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 ota_ctl_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 ota_ctl_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_effective_date in date
187 ,p_rec in ota_ctl_shd.g_rec_type
188 ) is
189 --
190 l_proc varchar2(72) := g_package||'post_update';
191 --
192 Begin
193 hr_utility.set_location('Entering:'||l_proc, 5);
194 begin
195 --
196 ota_ctl_rku.after_update
197 (p_effective_date => p_effective_date
198 ,p_certification_id
199 => p_rec.certification_id
200 ,p_language
201 => p_rec.language
202 ,p_name
203 => p_rec.name
204 ,p_description
205 => p_rec.description
206 ,p_objectives
207 => p_rec.objectives
208 ,p_purpose
209 => p_rec.purpose
210 ,p_keywords
211 => p_rec.keywords
212 ,p_end_date_comments
213 => p_rec.end_date_comments
214 ,p_initial_period_comments
215 => p_rec.initial_period_comments
216 ,p_renewal_period_comments
217 => p_rec.renewal_period_comments
218 ,p_source_lang
219 => p_rec.source_lang
220 ,p_name_o
221 => ota_ctl_shd.g_old_rec.name
222 ,p_description_o
223 => ota_ctl_shd.g_old_rec.description
224 ,p_objectives_o
225 => ota_ctl_shd.g_old_rec.objectives
226 ,p_purpose_o
227 => ota_ctl_shd.g_old_rec.purpose
228 ,p_keywords_o
229 => ota_ctl_shd.g_old_rec.keywords
230 ,p_end_date_comments_o
231 => ota_ctl_shd.g_old_rec.end_date_comments
232 ,p_initial_period_comments_o
233 => ota_ctl_shd.g_old_rec.initial_period_comments
234 ,p_renewal_period_comments_o
235 => ota_ctl_shd.g_old_rec.renewal_period_comments
236 ,p_source_lang_o
237 => ota_ctl_shd.g_old_rec.source_lang
238 );
239 --
240 exception
241 --
242 when hr_api.cannot_find_prog_unit then
243 --
244 hr_api.cannot_find_prog_unit_error
245 (p_module_name => 'OTA_CERTIFICATIONS_TL'
246 ,p_hook_type => 'AU');
247 --
248 end;
249 --
250 hr_utility.set_location(' Leaving:'||l_proc, 10);
251 End post_update;
252 --
253 -- ----------------------------------------------------------------------------
254 -- |-----------------------------< convert_defs >-----------------------------|
255 -- ----------------------------------------------------------------------------
256 -- {Start Of Comments}
257 --
258 -- Description:
259 -- The Convert_Defs procedure has one very important function:
260 -- It must return the record structure for the row with all system defaulted
261 -- values converted into its corresponding parameter value for update. When
262 -- we attempt to update a row through the Upd process , certain
263 -- parameters can be defaulted which enables flexibility in the calling of
264 -- the upd process (e.g. only attributes which need to be updated need to be
265 -- specified). For the upd process to determine which attributes
266 -- have NOT been specified we need to check if the parameter has a reserved
267 -- system default value. Therefore, for all parameters which have a
268 -- corresponding reserved system default mechanism specified we need to
269 -- check if a system default is being used. If a system default is being
270 -- used then we convert the defaulted value into its corresponding attribute
271 -- value held in the g_old_rec data structure.
272 --
273 -- Prerequisites:
274 -- This private function can only be called from the upd process.
275 --
276 -- In Parameters:
277 -- A Pl/Sql record structure.
278 --
279 -- Post Success:
280 -- The record structure will be returned with all system defaulted parameter
281 -- values converted into its current row attribute value.
282 --
283 -- Post Failure:
284 -- No direct error handling is required within this function. Any possible
285 -- errors within this procedure will be a PL/SQL value error due to
286 -- conversion of datatypes or data lengths.
287 --
288 -- Developer Implementation Notes:
289 -- None.
290 --
291 -- Access Status:
292 -- Internal Row Handler Use Only.
293 --
294 -- {End Of Comments}
295 -- ----------------------------------------------------------------------------
296 Procedure convert_defs
297 (p_rec in out nocopy ota_ctl_shd.g_rec_type
298 ) is
299 --
300 Begin
301 --
302 -- We must now examine each argument value in the
303 -- p_rec plsql record structure
304 -- to see if a system default is being used. If a system default
305 -- is being used then we must set to the 'current' argument value.
306 --
307 If (p_rec.name = hr_api.g_varchar2) then
308 p_rec.name :=
309 ota_ctl_shd.g_old_rec.name;
310 End If;
311 If (p_rec.description = hr_api.g_varchar2) then
312 p_rec.description :=
313 ota_ctl_shd.g_old_rec.description;
314 End If;
315 If (p_rec.objectives = hr_api.g_varchar2) then
316 p_rec.objectives :=
317 ota_ctl_shd.g_old_rec.objectives;
318 End If;
319 If (p_rec.purpose = hr_api.g_varchar2) then
320 p_rec.purpose :=
321 ota_ctl_shd.g_old_rec.purpose;
322 End If;
323 If (p_rec.keywords = hr_api.g_varchar2) then
324 p_rec.keywords :=
325 ota_ctl_shd.g_old_rec.keywords;
326 End If;
327 If (p_rec.end_date_comments = hr_api.g_varchar2) then
328 p_rec.end_date_comments :=
329 ota_ctl_shd.g_old_rec.end_date_comments;
330 End If;
331 If (p_rec.initial_period_comments = hr_api.g_varchar2) then
332 p_rec.initial_period_comments :=
333 ota_ctl_shd.g_old_rec.initial_period_comments;
334 End If;
335 If (p_rec.renewal_period_comments = hr_api.g_varchar2) then
336 p_rec.renewal_period_comments :=
337 ota_ctl_shd.g_old_rec.renewal_period_comments;
338 End If;
339 If (p_rec.source_lang = hr_api.g_varchar2) then
340 p_rec.source_lang :=
341 ota_ctl_shd.g_old_rec.source_lang;
342 End If;
343 --
344 End convert_defs;
345 --
346 -- ----------------------------------------------------------------------------
347 -- |---------------------------------< upd >----------------------------------|
348 -- ----------------------------------------------------------------------------
349 Procedure upd
350 (p_effective_date in date
351 ,p_rec in out nocopy ota_ctl_shd.g_rec_type
352 ) is
353 --
354 l_proc varchar2(72) := g_package||'upd';
355 --
356 Begin
357 hr_utility.set_location('Entering:'||l_proc, 5);
358 --
359 -- We must lock the row which we need to update.
360 --
361 ota_ctl_shd.lck
362 (p_rec.certification_id
363 ,p_rec.language
364 );
365 --
366 -- 1. During an update system defaults are used to determine if
367 -- arguments have been defaulted or not. We must therefore
368 -- derive the full record structure values to be updated.
369 --
370 -- 2. Call the supporting update validate operations.
371 --
372 convert_defs(p_rec);
373 ota_ctl_bus.update_validate
374 (p_effective_date
375 ,p_rec
376 );
377 --
378 -- Call to raise any errors on multi-message list
379 hr_multi_message.end_validation_set;
380 --
381 -- Call the supporting pre-update operation
382 --
383 ota_ctl_upd.pre_update(p_rec);
384 --
385 -- Update the row.
386 --
387 ota_ctl_upd.update_dml(p_rec);
388 --
389 -- Call the supporting post-update operation
390 --
391 ota_ctl_upd.post_update
392 (p_effective_date
393 ,p_rec
394 );
395 --
396 -- Call to raise any errors on multi-message list
397 hr_multi_message.end_validation_set;
398 End upd;
399 --
400 -- ----------------------------------------------------------------------------
401 -- |---------------------------------< upd >----------------------------------|
402 -- ----------------------------------------------------------------------------
403 Procedure upd
404 (p_effective_date in date
405 ,p_certification_id in number
406 ,p_language in varchar2
407 ,p_name in varchar2 default hr_api.g_varchar2
408 ,p_source_lang in varchar2 default hr_api.g_varchar2
409 ,p_description in varchar2 default hr_api.g_varchar2
410 ,p_objectives in varchar2 default hr_api.g_varchar2
411 ,p_purpose in varchar2 default hr_api.g_varchar2
412 ,p_keywords in varchar2 default hr_api.g_varchar2
413 ,p_end_date_comments in varchar2 default hr_api.g_varchar2
414 ,p_initial_period_comments in varchar2 default hr_api.g_varchar2
415 ,p_renewal_period_comments in varchar2 default hr_api.g_varchar2
416 ) is
417 --
418 l_rec ota_ctl_shd.g_rec_type;
419 l_proc varchar2(72) := g_package||'upd';
420 --
421 Begin
422 hr_utility.set_location('Entering:'||l_proc, 5);
423 --
424 -- Call conversion function to turn arguments into the
425 -- l_rec structure.
426 --
427 l_rec :=
428 ota_ctl_shd.convert_args
429 (p_certification_id
430 ,p_language
431 ,p_name
432 ,p_description
433 ,p_objectives
434 ,p_purpose
435 ,p_keywords
436 ,p_end_date_comments
437 ,p_initial_period_comments
438 ,p_renewal_period_comments
439 ,p_source_lang
440 );
441 --
442 -- Having converted the arguments into the
443 -- plsql record structure we call the corresponding record
444 -- business process.
445 --
446 ota_ctl_upd.upd
447 (p_effective_date
448 ,l_rec
449 );
450 --
451 --
452 hr_utility.set_location(' Leaving:'||l_proc, 10);
453 End upd;
454 --
455 -- ----------------------------------------------------------------------------
456 -- |------------------------------< upd_tl >----------------------------------|
457 -- ----------------------------------------------------------------------------
458 Procedure upd_tl
459 (p_effective_date in date
460 ,p_language_code in varchar2
461 ,p_certification_id in number
462 ,p_name in varchar2 default hr_api.g_varchar2
463 ,p_description in varchar2 default hr_api.g_varchar2
464 ,p_objectives in varchar2 default hr_api.g_varchar2
465 ,p_purpose in varchar2 default hr_api.g_varchar2
466 ,p_keywords in varchar2 default hr_api.g_varchar2
467 ,p_end_date_comments in varchar2 default hr_api.g_varchar2
468 ,p_initial_period_comments in varchar2 default hr_api.g_varchar2
469 ,p_renewal_period_comments in varchar2 default hr_api.g_varchar2
470 ) is
471 --
472 -- Cursor to obtain the translation rows where the language or
473 -- source_lang match the specified language.
474 --
475 cursor csr_upd_langs is
476 select ctl.language
477 from ota_certifications_tl ctl
478 where ctl.certification_id = p_certification_id
479 and p_language_code in (ctl.language
480 ,ctl.source_lang);
481 --
482 l_proc varchar2(72) := g_package||'upd_tl';
483 --
484 Begin
485 hr_utility.set_location('Entering:'||l_proc,10);
486 --
487 -- Update the translated values for every matching row
488 -- setting SOURCE_LANG to the specified language.
489 --
490 for l_lang in csr_upd_langs loop
491 ota_ctl_upd.upd
492 (p_effective_date => p_effective_date
493 ,p_certification_id => p_certification_id
494 ,p_language => l_lang.language
495 ,p_source_lang => p_language_code
496 ,p_name => p_name
497 ,p_description => p_description
498 ,p_objectives => p_objectives
499 ,p_purpose => p_purpose
500 ,p_keywords => p_keywords
501 ,p_end_date_comments => p_end_date_comments
502 ,p_initial_period_comments => p_initial_period_comments
503 ,p_renewal_period_comments => p_renewal_period_comments
504 );
505 end loop;
506 --
507 hr_utility.set_location(' Leaving:'||l_proc,20);
508 End upd_tl;
509 --
510 end ota_ctl_upd;