DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_IPT_UPD

Source


1 Package Body hr_ipt_upd as
2 /* $Header: hriptrhi.pkb 115.9 2003/05/06 17:43:05 adhunter noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  hr_ipt_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 hr_ipt_shd.g_rec_type
56   ) is
57 --
58   l_proc  varchar2(72) := g_package||'update_dml';
59 --
60 Begin
61   hr_utility.set_location('Entering:'||l_proc, 5);
62   --
63   --
64   --
65   --
66   -- Update the hr_item_properties_tl Row
67   --
68   update hr_item_properties_tl
69     set
70      item_property_id                = p_rec.item_property_id
71     ,language                        = p_rec.language
72     ,source_lang                     = p_rec.source_lang
73     ,default_value                   = p_rec.default_value
74     ,information_prompt              = p_rec.information_prompt
75     ,label                           = p_rec.label
76     ,prompt_text                     = p_rec.prompt_text
77     ,tooltip_text                    = p_rec.tooltip_text
78     where item_property_id = p_rec.item_property_id
79     and language = p_rec.language;
80   --
81   --
82   --
83   hr_utility.set_location(' Leaving:'||l_proc, 10);
84 --
85 Exception
86   When hr_api.check_integrity_violated Then
87     -- A check constraint has been violated
88     --
89     hr_ipt_shd.constraint_error
90       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
91   When hr_api.parent_integrity_violated Then
92     -- Parent integrity has been violated
93     --
94     hr_ipt_shd.constraint_error
95       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
96   When hr_api.unique_integrity_violated Then
97     -- Unique integrity has been violated
98     --
99     hr_ipt_shd.constraint_error
100       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
101   When Others Then
102     --
103     Raise;
104 End update_dml;
105 --
106 -- ----------------------------------------------------------------------------
107 -- |------------------------------< pre_update >------------------------------|
108 -- ----------------------------------------------------------------------------
109 -- {Start Of Comments}
110 --
111 -- Description:
112 --   This private procedure contains any processing which is required before
113 --   the update dml.
114 --
115 -- Prerequisites:
116 --   This is an internal procedure which is called from the upd procedure.
117 --
118 -- In Parameters:
119 --   A Pl/Sql record structure.
120 --
121 -- Post Success:
122 --   Processing continues.
123 --
124 -- Post Failure:
125 --   If an error has occurred, an error message and exception wil be raised
126 --   but not handled.
127 --
128 -- Developer Implementation Notes:
129 --   Any pre-processing required before the update dml is issued should be
130 --   coded within this procedure. It is important to note that any 3rd party
131 --   maintenance should be reviewed before placing in this procedure.
132 --
133 -- Access Status:
134 --   Internal Row Handler Use Only.
135 --
136 -- {End Of Comments}
137 -- ----------------------------------------------------------------------------
138 Procedure pre_update
139   (p_rec in hr_ipt_shd.g_rec_type
140   ) is
141 --
142   l_proc  varchar2(72) := g_package||'pre_update';
143 --
144 Begin
145   hr_utility.set_location('Entering:'||l_proc, 5);
146   --
147   hr_utility.set_location(' Leaving:'||l_proc, 10);
148 End pre_update;
149 --
150 -- ----------------------------------------------------------------------------
151 -- |-----------------------------< post_update >------------------------------|
152 -- ----------------------------------------------------------------------------
153 -- {Start Of Comments}
154 --
155 -- Description:
156 --   This private procedure contains any processing which is required after the
157 --   update dml.
158 --
159 -- Prerequisites:
160 --   This is an internal procedure which is called from the upd procedure.
161 --
162 -- In Parameters:
163 --   A Pl/Sql record structure.
164 --
165 -- Post Success:
166 --   Processing continues.
167 --
168 -- Post Failure:
169 --   If an error has occurred, an error message and exception will be raised
170 --   but not handled.
171 --
172 -- Developer Implementation Notes:
173 --   Any post-processing required after the update dml is issued should be
174 --   coded within this procedure. It is important to note that any 3rd party
175 --   maintenance should be reviewed before placing in this procedure.
176 --
177 -- Access Status:
178 --   Internal Row Handler Use Only.
179 --
180 -- {End Of Comments}
181 -- ----------------------------------------------------------------------------
182 Procedure post_update
183   (p_rec                          in hr_ipt_shd.g_rec_type
184   ) is
185 --
186   l_proc  varchar2(72) := g_package||'post_update';
187 --
188 Begin
189   hr_utility.set_location('Entering:'||l_proc, 5);
190   begin
191     --
192     hr_ipt_rku.after_update
193       (p_item_property_id
194       => p_rec.item_property_id
195       ,p_language
196       => p_rec.language
197       ,p_source_lang
198       => p_rec.source_lang
199       ,p_default_value
200       => p_rec.default_value
201       ,p_information_prompt
202       => p_rec.information_prompt
203       ,p_label
204       => p_rec.label
205       ,p_prompt_text
206       => p_rec.prompt_text
207       ,p_tooltip_text
208       => p_rec.tooltip_text
209       ,p_source_lang_o
210       => hr_ipt_shd.g_old_rec.source_lang
211       ,p_default_value_o
212       => hr_ipt_shd.g_old_rec.default_value
213       ,p_information_prompt_o
214       => hr_ipt_shd.g_old_rec.information_prompt
215       ,p_label_o
216       => hr_ipt_shd.g_old_rec.label
217       ,p_prompt_text_o
218       => hr_ipt_shd.g_old_rec.prompt_text
219       ,p_tooltip_text_o
220       => hr_ipt_shd.g_old_rec.tooltip_text
221       );
222     --
223   exception
224     --
225     when hr_api.cannot_find_prog_unit then
226       --
227       hr_api.cannot_find_prog_unit_error
228         (p_module_name => 'HR_ITEM_PROPERTIES_TL'
229         ,p_hook_type   => 'AU');
230       --
231   end;
232   --
233   hr_utility.set_location(' Leaving:'||l_proc, 10);
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 hr_ipt_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.source_lang = hr_api.g_varchar2) then
291     p_rec.source_lang :=
292     hr_ipt_shd.g_old_rec.source_lang;
293   End If;
294   If (p_rec.default_value = hr_api.g_varchar2) then
295     p_rec.default_value :=
296     hr_ipt_shd.g_old_rec.default_value;
297   End If;
298   If (p_rec.information_prompt = hr_api.g_varchar2) then
299     p_rec.information_prompt :=
300     hr_ipt_shd.g_old_rec.information_prompt;
301   End If;
302   If (p_rec.label = hr_api.g_varchar2) then
303     p_rec.label :=
304     hr_ipt_shd.g_old_rec.label;
305   End If;
306   If (p_rec.prompt_text = hr_api.g_varchar2) then
307     p_rec.prompt_text :=
308     hr_ipt_shd.g_old_rec.prompt_text;
309   End If;
310   If (p_rec.tooltip_text = hr_api.g_varchar2) then
311     p_rec.tooltip_text :=
312     hr_ipt_shd.g_old_rec.tooltip_text;
313   End If;
314   --
315 End convert_defs;
316 --
317 -- ----------------------------------------------------------------------------
318 -- |---------------------------------< upd >----------------------------------|
319 -- ----------------------------------------------------------------------------
320 Procedure upd
321   (p_rec                          in out nocopy hr_ipt_shd.g_rec_type
322   ) is
323 --
324   l_proc  varchar2(72) := g_package||'upd';
325 --
326 Begin
327   hr_utility.set_location('Entering:'||l_proc, 5);
328   --
329   -- We must lock the row which we need to update.
330   --
331   hr_ipt_shd.lck
332     (p_rec.item_property_id
333     ,p_rec.language
334     );
335   --
336   -- 1. During an update system defaults are used to determine if
337   --    arguments have been defaulted or not. We must therefore
338   --    derive the full record structure values to be updated.
339   --
340   -- 2. Call the supporting update validate operations.
341   --
342   convert_defs(p_rec);
343   hr_ipt_bus.update_validate
344      (p_rec
345      );
346   --
347   -- Call the supporting pre-update operation
348   --
349   hr_ipt_upd.pre_update(p_rec);
350   --
351   -- Update the row.
352   --
353   hr_ipt_upd.update_dml(p_rec);
354   --
355   -- Call the supporting post-update operation
356   --
357   hr_ipt_upd.post_update
358      (p_rec
359      );
360 End upd;
361 --
362 -- ----------------------------------------------------------------------------
363 -- |---------------------------------< upd >----------------------------------|
364 -- ----------------------------------------------------------------------------
365 Procedure upd
366   (p_item_property_id             in     number
367   ,p_language                     in     varchar2
368   ,p_source_lang                  in     varchar2  default hr_api.g_varchar2
369   ,p_default_value                in     varchar2  default hr_api.g_varchar2
370   ,p_information_prompt           in     varchar2  default hr_api.g_varchar2
371   ,p_label                        in     varchar2  default hr_api.g_varchar2
372   ,p_prompt_text                  in     varchar2  default hr_api.g_varchar2
373   ,p_tooltip_text                 in     varchar2  default hr_api.g_varchar2
374   ) is
375 --
376   l_rec	  hr_ipt_shd.g_rec_type;
377   l_proc  varchar2(72) := g_package||'upd';
378 --
379 Begin
380   hr_utility.set_location('Entering:'||l_proc, 5);
381   --
382   -- Call conversion function to turn arguments into the
383   -- l_rec structure.
384   --
385   l_rec :=
386   hr_ipt_shd.convert_args
387   (p_item_property_id
388   ,p_language
389   ,p_source_lang
390   ,p_default_value
391   ,p_information_prompt
392   ,p_label
393   ,p_prompt_text
394   ,p_tooltip_text
395   );
396   --
397   -- Having converted the arguments into the
398   -- plsql record structure we call the corresponding record
399   -- business process.
400   --
401   hr_ipt_upd.upd
402      (l_rec
403      );
404   --
405   --
406   hr_utility.set_location(' Leaving:'||l_proc, 10);
407 End upd;
408 --
409 -- ----------------------------------------------------------------------------
410 -- |------------------------------< upd_tl >----------------------------------|
411 -- ----------------------------------------------------------------------------
412 Procedure upd_tl
413   (p_language_code                 in varchar2
414   ,p_item_property_id             in number
415   ,p_default_value                in varchar2 default hr_api.g_varchar2
416   ,p_information_prompt           in varchar2 default hr_api.g_varchar2
417   ,p_label                        in varchar2 default hr_api.g_varchar2
418   ,p_prompt_text                  in varchar2 default hr_api.g_varchar2
419   ,p_tooltip_text                 in varchar2 default hr_api.g_varchar2
420   ) is
421   --
422   -- Cursor to obtain the translation rows where the language or
423   -- source_lang match the specified language.
424   --
425   cursor csr_upd_langs is
426     select ipt.language
427       from hr_item_properties_tl ipt
428      where ipt.item_property_id = p_item_property_id
429        and p_language_code in (ipt.language
430                               ,ipt.source_lang);
431   --
432   l_proc  varchar2(72) := g_package||'upd_tl';
433   --
434 Begin
435   hr_utility.set_location('Entering:'||l_proc,10);
436   --
437   -- Update the translated values for every matching row
438   -- setting SOURCE_LANG to the specified language.
439   --
440   for l_lang in csr_upd_langs loop
441     hr_ipt_upd.upd
442       (p_item_property_id            => p_item_property_id
443       ,p_language                    => l_lang.language
444       ,p_source_lang                 => p_language_code
445       ,p_default_value               => p_default_value
446       ,p_information_prompt          => p_information_prompt
447       ,p_label                       => p_label
448       ,p_prompt_text                 => p_prompt_text
449       ,p_tooltip_text                => p_tooltip_text
450       );
451   end loop;
452   --
453   hr_utility.set_location(' Leaving:'||l_proc,20);
454 End upd_tl;
455 --
456 end hr_ipt_upd;