DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_LOT_UPD

Source


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