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