DBA Data[Home] [Help]

PACKAGE BODY: APPS.AME_CAL_UPD

Source


1 Package Body ame_cal_upd as
2 /* $Header: amcalrhi.pkb 120.2 2006/01/03 22:52 tkolla noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ame_cal_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_cal_shd.g_rec_type
56   ) is
57 --
58   l_proc  varchar2(72) := g_package||'update_dml';
59   l_current_user_id   number;
60   l_created_by        number;
61   l_last_updated_by   number;
62   l_last_update_login number;
63   l_creation_date     date;
64   l_last_update_date  date;
65 
66 --
67 Begin
68   hr_utility.set_location('Entering:'||l_proc, 5);
69   --
70   --
71   --
72   l_current_user_id := fnd_global.user_id;
73   l_last_update_date   := sysdate;
74   l_last_updated_by    := l_current_user_id;
75   l_last_update_login  := l_current_user_id;
76   --
77   -- Update the ame_calling_apps_tl Row
78   --
79   update ame_calling_apps_tl
80     set
81      application_id                  = p_rec.application_id
82     ,language                        = p_rec.language
83     ,source_lang                     = p_rec.source_lang
84     ,application_name                = p_rec.application_name
85     ,last_update_date                = l_last_update_date
86     ,last_updated_by                 = l_last_updated_by
87     ,last_update_login               = l_last_update_login
88     where application_id = p_rec.application_id
89     and language = p_rec.language;
90   --
91   --
92   --
93   hr_utility.set_location(' Leaving:'||l_proc, 10);
94 --
95 Exception
96   When hr_api.check_integrity_violated Then
97     -- A check constraint has been violated
98     --
99     ame_cal_shd.constraint_error
100       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
101   When hr_api.parent_integrity_violated Then
102     -- Parent integrity has been violated
103     --
104     ame_cal_shd.constraint_error
105       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
106   When hr_api.unique_integrity_violated Then
107     -- Unique integrity has been violated
108     --
109     ame_cal_shd.constraint_error
110       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
111   When Others Then
112     --
113     Raise;
114 End update_dml;
115 --
116 -- ----------------------------------------------------------------------------
117 -- |------------------------------< pre_update >------------------------------|
118 -- ----------------------------------------------------------------------------
119 -- {Start Of Comments}
120 --
121 -- Description:
122 --   This private procedure contains any processing which is required before
123 --   the update dml.
124 --
125 -- Prerequisites:
126 --   This is an internal procedure which is called from the upd procedure.
127 --
128 -- In Parameters:
129 --   A Pl/Sql record structure.
130 --
131 -- Post Success:
132 --   Processing continues.
133 --
134 -- Post Failure:
135 --   If an error has occurred, an error message and exception wil be raised
136 --   but not handled.
137 --
138 -- Developer Implementation Notes:
139 --   Any pre-processing required before the update dml is issued should be
140 --   coded within this procedure. It is important to note that any 3rd party
141 --   maintenance should be reviewed before placing in this procedure.
142 --
143 -- Access Status:
144 --   Internal Row Handler Use Only.
145 --
146 -- {End Of Comments}
147 -- ----------------------------------------------------------------------------
148 Procedure pre_update
149   (p_rec in ame_cal_shd.g_rec_type
150   ) is
151 --
152   l_proc  varchar2(72) := g_package||'pre_update';
153 --
154 Begin
155   hr_utility.set_location('Entering:'||l_proc, 5);
156   --
157   hr_utility.set_location(' Leaving:'||l_proc, 10);
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
167 --   the 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 ame_cal_shd.g_rec_type
194   ) is
195 --
196   l_proc  varchar2(72) := g_package||'post_update';
197 --
198 Begin
199   hr_utility.set_location('Entering:'||l_proc, 5);
200   begin
201     --
202     ame_cal_rku.after_update
203       (p_application_id
204       => p_rec.application_id
205       ,p_language
206       => p_rec.language
207       ,p_source_lang
208       => p_rec.source_lang
209       ,p_application_name
210       => p_rec.application_name
211       ,p_source_lang_o
212       => ame_cal_shd.g_old_rec.source_lang
213       ,p_application_name_o
214       => ame_cal_shd.g_old_rec.application_name
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_CALLING_APPS_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_cal_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_cal_shd.g_old_rec.source_lang;
287   End If;
288   If (p_rec.application_name = hr_api.g_varchar2) then
289     p_rec.application_name :=
290     ame_cal_shd.g_old_rec.application_name;
291   End If;
292   --
293 End convert_defs;
294 --
295 -- ----------------------------------------------------------------------------
296 -- |---------------------------------< upd >----------------------------------|
297 -- ----------------------------------------------------------------------------
298 Procedure upd
299   (p_rec                          in out nocopy ame_cal_shd.g_rec_type
300   ) is
301 --
302   l_proc  varchar2(72) := g_package||'upd';
303 --
304 Begin
305   hr_utility.set_location('Entering:'||l_proc, 5);
306   --
307   -- We must lock the row which we need to update.
308   --
309   ame_cal_shd.lck
310     (p_rec.application_id
311     ,p_rec.language
312     );
313   --
314   -- 1. During an update system defaults are used to determine if
315   --    arguments have been defaulted or not. We must therefore
316   --    derive the full record structure values to be updated.
317   --
318   -- 2. Call the supporting update validate operations.
319   --
320   convert_defs(p_rec);
321   ame_cal_bus.update_validate
322      (p_rec
323      );
324   --
325   -- Call to raise any errors on multi-message list
326   hr_multi_message.end_validation_set;
327   --
328   -- Call the supporting pre-update operation
329   --
330   ame_cal_upd.pre_update(p_rec);
331   --
332   -- Update the row.
333   --
334   ame_cal_upd.update_dml(p_rec);
335   --
336   -- Call the supporting post-update operation
337   --
338   ame_cal_upd.post_update
339      (p_rec
340      );
341   --
342   -- Call to raise any errors on multi-message list
343   hr_multi_message.end_validation_set;
344 End upd;
345 --
346 -- ----------------------------------------------------------------------------
347 -- |---------------------------------< upd >----------------------------------|
348 -- ----------------------------------------------------------------------------
349 Procedure upd
350   (p_application_id               in     number
351   ,p_language                     in     varchar2
352   ,p_source_lang                  in     varchar2  default hr_api.g_varchar2
353   ,p_application_name             in     varchar2  default hr_api.g_varchar2
354   ) is
355 --
356   l_rec   ame_cal_shd.g_rec_type;
357   l_proc  varchar2(72) := g_package||'upd';
358 --
359 Begin
360   hr_utility.set_location('Entering:'||l_proc, 5);
361   --
362   -- Call conversion function to turn arguments into the
363   -- l_rec structure.
364   --
365   l_rec :=
366   ame_cal_shd.convert_args
367   (p_application_id
368   ,p_language
369   ,p_source_lang
370   ,p_application_name
371   );
372   --
373   -- Having converted the arguments into the
374   -- plsql record structure we call the corresponding record
375   -- business process.
376   --
377   ame_cal_upd.upd
378      (l_rec
379      );
380   --
381   --
382   hr_utility.set_location(' Leaving:'||l_proc, 10);
383 End upd;
384 --
385 -- ----------------------------------------------------------------------------
386 -- |------------------------------< upd_tl >----------------------------------|
387 -- ----------------------------------------------------------------------------
388 Procedure upd_tl
389   (p_language_code                 in varchar2
390   ,p_application_id               in number
391   ,p_application_name             in varchar2 default hr_api.g_varchar2
392   ) is
393   --
394   -- Cursor to obtain the translation rows where the language or
395   -- source_lang match the specified language.
396   --
397   cursor csr_upd_langs is
398     select cal.language
399       from ame_calling_apps_tl cal
400      where cal.application_id = p_application_id
401        and p_language_code in (cal.language
402                               ,cal.source_lang);
403   --
404   l_proc  varchar2(72) := g_package||'upd_tl';
405   --
406 Begin
407   hr_utility.set_location('Entering:'||l_proc,10);
408   --
409   -- Update the translated values for every matching row
410   -- setting SOURCE_LANG to the specified language.
411   --
412   for l_lang in csr_upd_langs loop
413     ame_cal_upd.upd
414       (p_application_id              => p_application_id
415       ,p_language                    => l_lang.language
416       ,p_source_lang                 => p_language_code
417       ,p_application_name            => p_application_name
418       );
419   end loop;
420   --
421   hr_utility.set_location(' Leaving:'||l_proc,20);
422 End upd_tl;
423 --
424 end ame_cal_upd;