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