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