DBA Data[Home] [Help]

PACKAGE BODY: APPS.AME_ACL_UPD

Source


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