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