DBA Data[Home] [Help]
Skip to content

PACKAGE BODY: APPS.HR_OPT_UPD

Source


1 Package Body hr_opt_upd as
2 /* $Header: hroptrhi.pkb 120.1 2005/09/29 07:03 santosin noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  hr_opt_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_opt_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   -- Increment the object version
64   p_rec.object_version_number := p_rec.object_version_number + 1;
65   --
66   --
67   --
68   -- Update the hr_ki_options Row
69   --
70   update hr_ki_options
71     set
72      option_id                       = p_rec.option_id
73      ,value                           = p_rec.value
74      ,encrypted                       =p_rec.encrypted
75     ,object_version_number           = p_rec.object_version_number
76     where option_id = p_rec.option_id;
77   --
78   --
79   --
80   hr_utility.set_location(' Leaving:'||l_proc, 10);
81 --
82 Exception
83   When hr_api.check_integrity_violated Then
84     -- A check constraint has been violated
85     --
86     hr_opt_shd.constraint_error
87       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
88   When hr_api.parent_integrity_violated Then
89     -- Parent integrity has been violated
90     --
91     hr_opt_shd.constraint_error
92       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
93   When hr_api.unique_integrity_violated Then
94     -- Unique integrity has been violated
95     --
96     hr_opt_shd.constraint_error
97       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
98   When Others Then
99     --
100     Raise;
101 End update_dml;
102 --
103 -- ----------------------------------------------------------------------------
104 -- |------------------------------< pre_update >------------------------------|
105 -- ----------------------------------------------------------------------------
106 -- {Start Of Comments}
107 --
108 -- Description:
109 --   This private procedure contains any processing which is required before
110 --   the update dml.
111 --
112 -- Prerequisites:
113 --   This is an internal procedure which is called from the upd procedure.
114 --
115 -- In Parameters:
116 --   A Pl/Sql record structure.
117 --
118 -- Post Success:
119 --   Processing continues.
120 --
121 -- Post Failure:
122 --   If an error has occurred, an error message and exception wil be raised
123 --   but not handled.
124 --
125 -- Developer Implementation Notes:
126 --   Any pre-processing required before the update dml is issued should be
127 --   coded within this procedure. It is important to note that any 3rd party
128 --   maintenance should be reviewed before placing in this procedure.
129 --
130 -- Access Status:
131 --   Internal Row Handler Use Only.
132 --
133 -- {End Of Comments}
134 -- ----------------------------------------------------------------------------
135 Procedure pre_update
136   (p_rec in out nocopy hr_opt_shd.g_rec_type
137   ) is
138 --
139   l_proc  varchar2(72) := g_package||'pre_update';
140    l_option_type_id number;
141 --
142 Begin
143    select option_type_id
144      into l_option_type_id
145         from hr_ki_option_types
146            where option_type_key = 'PASSWORD';
147   hr_utility.set_location('Entering:'||l_proc, 5);
148 
149   --
150   if p_rec.option_type_id = l_option_type_id then
151       FND_VAULT.put('KI',p_rec.integration_id ||'#' || p_rec.option_type_id || '#' || p_rec.option_level_id || '#' || p_rec.option_id,p_rec.value);
152       p_rec.value := p_rec.integration_id ||'#' || p_rec.option_type_id || '#' || p_rec.option_level_id || '#' || p_rec.option_id;
153 
154   elsif upper(p_rec.encrypted) ='Y' then
155         --p_rec.value :=icx_call.encrypt(p_rec.value);
156           FND_VAULT.put('KI',p_rec.integration_id ||'#' || p_rec.option_type_id || '#' || p_rec.option_level_id || '#' || p_rec.option_id,p_rec.value);
157           p_rec.value := p_rec.integration_id ||'#' || p_rec.option_type_id || '#' || p_rec.option_level_id || '#' || p_rec.option_id;
158   end if;
159   /*if upper(p_rec.encrypted) ='Y' then
160         p_rec.value :=icx_call.encrypt(p_rec.value);
161   end if;*/
162 
163   hr_utility.set_location(' Leaving:'||l_proc, 10);
164 End pre_update;
165 --
166 -- ----------------------------------------------------------------------------
167 -- |-----------------------------< post_update >------------------------------|
168 -- ----------------------------------------------------------------------------
169 -- {Start Of Comments}
170 --
171 -- Description:
172 --   This private procedure contains any processing which is required after
173 --   the update dml.
174 --
175 -- Prerequisites:
176 --   This is an internal procedure which is called from the upd procedure.
177 --
178 -- In Parameters:
179 --   A Pl/Sql record structure.
180 --
181 -- Post Success:
182 --   Processing continues.
183 --
184 -- Post Failure:
185 --   If an error has occurred, an error message and exception will be raised
186 --   but not handled.
187 --
188 -- Developer Implementation Notes:
189 --   Any post-processing required after the update dml is issued should be
190 --   coded within this procedure. It is important to note that any 3rd party
191 --   maintenance should be reviewed before placing in this procedure.
192 --
193 -- Access Status:
194 --   Internal Row Handler Use Only.
195 --
196 -- {End Of Comments}
197 -- ----------------------------------------------------------------------------
198 Procedure post_update
199   (
200   p_rec                          in hr_opt_shd.g_rec_type
201   ) is
202 --
203   l_proc  varchar2(72) := g_package||'post_update';
204 --
205 Begin
206   hr_utility.set_location('Entering:'||l_proc, 5);
207   begin
208     --
209     hr_opt_rku.after_update
210       (
211       p_option_id
212       => p_rec.option_id
213       ,p_value
214       => p_rec.value
215       ,p_encrypted
216       => p_rec.encrypted
217       ,p_object_version_number
218       => p_rec.object_version_number
219       ,p_option_type_id_o
220       => hr_opt_shd.g_old_rec.option_type_id
221       ,p_option_level_o
222       => hr_opt_shd.g_old_rec.option_level
223       ,p_option_level_id_o
224       => hr_opt_shd.g_old_rec.option_level_id
225       ,p_value_o
226       => hr_opt_shd.g_old_rec.value
227       ,p_encrypted_o
228       => hr_opt_shd.g_old_rec.encrypted
229       ,p_integration_id_o
230       => hr_opt_shd.g_old_rec.integration_id
231       ,p_object_version_number_o
232       => hr_opt_shd.g_old_rec.object_version_number
233       );
234     --
235   exception
236     --
237     when hr_api.cannot_find_prog_unit then
238       --
239       hr_api.cannot_find_prog_unit_error
240         (p_module_name => 'HR_KI_OPTIONS'
241         ,p_hook_type   => 'AU');
242       --
243   end;
244   --
245   hr_utility.set_location(' Leaving:'||l_proc, 10);
246 End post_update;
247 --
248 -- ----------------------------------------------------------------------------
249 -- |-----------------------------< convert_defs >-----------------------------|
250 -- ----------------------------------------------------------------------------
251 -- {Start Of Comments}
252 --
253 -- Description:
254 --   The Convert_Defs procedure has one very important function:
255 --   It must return the record structure for the row with all system defaulted
256 --   values converted into its corresponding parameter value for update. When
257 --   we attempt to update a row through the Upd process , certain
258 --   parameters can be defaulted which enables flexibility in the calling of
259 --   the upd process (e.g. only attributes which need to be updated need to be
260 --   specified). For the upd process to determine which attributes
261 --   have NOT been specified we need to check if the parameter has a reserved
262 --   system default value. Therefore, for all parameters which have a
263 --   corresponding reserved system default mechanism specified we need to
264 --   check if a system default is being used. If a system default is being
265 --   used then we convert the defaulted value into its corresponding attribute
266 --   value held in the g_old_rec data structure.
267 --
268 -- Prerequisites:
269 --   This private function can only be called from the upd process.
270 --
271 -- In Parameters:
272 --   A Pl/Sql record structure.
273 --
274 -- Post Success:
275 --   The record structure will be returned with all system defaulted parameter
276 --   values converted into its current row attribute value.
277 --
278 -- Post Failure:
279 --   No direct error handling is required within this function. Any possible
280 --   errors within this procedure will be a PL/SQL value error due to
281 --   conversion of datatypes or data lengths.
282 --
283 -- Developer Implementation Notes:
284 --   None.
285 --
286 -- Access Status:
287 --   Internal Row Handler Use Only.
288 --
289 -- {End Of Comments}
290 -- ----------------------------------------------------------------------------
291 Procedure convert_defs
292   (p_rec in out nocopy hr_opt_shd.g_rec_type
293   ) is
294 --
295 Begin
296   --
297   -- We must now examine each argument value in the
298   -- p_rec plsql record structure
299   -- to see if a system default is being used. If a system default
300   -- is being used then we must set to the 'current' argument value.
301   --
302   If (p_rec.option_type_id = hr_api.g_number) then
303     p_rec.option_type_id :=
304     hr_opt_shd.g_old_rec.option_type_id;
305   End If;
306   If (p_rec.option_level = hr_api.g_number) then
307     p_rec.option_level :=
308     hr_opt_shd.g_old_rec.option_level;
309   End If;
310   If (p_rec.option_level_id = hr_api.g_varchar2) then
311     p_rec.option_level_id :=
312     hr_opt_shd.g_old_rec.option_level_id;
313   End If;
314   If (p_rec.value = hr_api.g_varchar2) then
315     p_rec.value :=
316     hr_opt_shd.g_old_rec.value;
317   End If;
318   If (p_rec.encrypted = hr_api.g_varchar2) then
319     p_rec.encrypted :=
320     hr_opt_shd.g_old_rec.encrypted;
321   End If;
322   If (p_rec.integration_id = hr_api.g_number) then
323     p_rec.integration_id :=
324     hr_opt_shd.g_old_rec.integration_id;
325   End If;
326   --
327 End convert_defs;
328 --
329 -- ----------------------------------------------------------------------------
330 -- |---------------------------------< upd >----------------------------------|
331 -- ----------------------------------------------------------------------------
332 Procedure upd
333   (
334   p_rec                          in out nocopy hr_opt_shd.g_rec_type
335   ) is
336 --
337   l_proc  varchar2(72) := g_package||'upd';
338 --
339 Begin
340   hr_utility.set_location('Entering:'||l_proc, 5);
341   --
342   -- We must lock the row which we need to update.
343   --
344   hr_opt_shd.lck
345     (p_rec.option_id
346     ,p_rec.object_version_number
347     );
348   --
349   -- 1. During an update system defaults are used to determine if
350   --    arguments have been defaulted or not. We must therefore
351   --    derive the full record structure values to be updated.
352   --
353   -- 2. Call the supporting update validate operations.
354   --
355   convert_defs(p_rec);
356   hr_opt_bus.update_validate
357      (
358      p_rec
359      );
360   --
361   -- Call to raise any errors on multi-message list
362   hr_multi_message.end_validation_set;
363   --
364   -- Call the supporting pre-update operation
365   --
366   hr_opt_upd.pre_update(p_rec);
367   --
368   -- Update the row.
369   --
370   hr_opt_upd.update_dml(p_rec);
371   --
372   -- Call the supporting post-update operation
373   --
374   hr_opt_upd.post_update
375      (
376      p_rec
377      );
378   --
379   -- Call to raise any errors on multi-message list
380   hr_multi_message.end_validation_set;
381 End upd;
382 --
383 -- ----------------------------------------------------------------------------
384 -- |---------------------------------< upd >----------------------------------|
385 -- ----------------------------------------------------------------------------
386 Procedure upd
387   (
388    p_option_id                    in     number
389   ,p_object_version_number        in out nocopy number
390   ,p_value                        in     varchar2  default hr_api.g_varchar2
391   ,p_encrypted                    in     varchar2  default hr_api.g_varchar2
392   ) is
393 --
394   l_rec   hr_opt_shd.g_rec_type;
395   l_proc  varchar2(72) := g_package||'upd';
396 --
397 Begin
398   hr_utility.set_location('Entering:'||l_proc, 5);
399   --
400   -- Call conversion function to turn arguments into the
401   -- l_rec structure.
402   --
403   l_rec :=
404   hr_opt_shd.convert_args
405   (p_option_id
406   ,hr_api.g_number
407   ,hr_api.g_number
408   ,hr_api.g_varchar2
409   ,p_value
410   ,p_encrypted
411   ,hr_api.g_number
412   ,p_object_version_number
413   );
414   --
415   -- Having converted the arguments into the
416   -- plsql record structure we call the corresponding record
417   -- business process.
418   --
419   hr_opt_upd.upd
420      (
421      l_rec
422      );
423   p_object_version_number := l_rec.object_version_number;
424   --
425   hr_utility.set_location(' Leaving:'||l_proc, 10);
426 End upd;
427 --
428 end hr_opt_upd;