DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_STT_UPD

Source


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