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