DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_XCV_UPD

Source


1 Package Body ben_xcv_upd as
2 /* $Header: bexcvrhi.pkb 120.3 2006/04/11 11:18:40 tjesumic noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_xcv_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(p_rec in out nocopy ben_xcv_shd.g_rec_type) is
55 --
56   l_proc  varchar2(72) := g_package||'update_dml';
57 --
58 Begin
59   hr_utility.set_location('Entering:'||l_proc, 5);
60   --
61   -- Increment the object version
62   --
63   p_rec.object_version_number := p_rec.object_version_number + 1;
64   --
65   ben_xcv_shd.g_api_dml := true;  -- Set the api dml status
66   --
67   -- Update the ben_ext_crit_val Row
68   --
69   update ben_ext_crit_val
70   set
71   ext_crit_val_id                   = p_rec.ext_crit_val_id,
72   val_1                             = p_rec.val_1,
73   val_2                             = p_rec.val_2,
74   ext_crit_typ_id                   = p_rec.ext_crit_typ_id,
75   business_group_id                 = p_rec.business_group_id,
76   ext_crit_bg_id                    = p_rec.ext_crit_bg_id   ,
77   legislation_code		    = p_rec.legislation_code,
78   last_update_date                  = p_rec.last_update_date,
79   last_updated_by                   = p_rec.last_updated_by,
80   last_update_login                 = p_rec.last_update_login,
81   object_version_number             = p_rec.object_version_number
82   where ext_crit_val_id = p_rec.ext_crit_val_id;
83   --
84   ben_xcv_shd.g_api_dml := false;   -- Unset the api dml status
85   --
86   hr_utility.set_location(' Leaving:'||l_proc, 10);
87 --
88 Exception
89   When hr_api.check_integrity_violated Then
90     -- A check constraint has been violated
91     ben_xcv_shd.g_api_dml := false;   -- Unset the api dml status
92     ben_xcv_shd.constraint_error
93       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
94   When hr_api.parent_integrity_violated Then
95     -- Parent integrity has been violated
96     ben_xcv_shd.g_api_dml := false;   -- Unset the api dml status
97     ben_xcv_shd.constraint_error
98       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
99   When hr_api.unique_integrity_violated Then
100     -- Unique integrity has been violated
101     ben_xcv_shd.g_api_dml := false;   -- Unset the api dml status
102     ben_xcv_shd.constraint_error
103       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
104   When Others Then
105     ben_xcv_shd.g_api_dml := false;   -- Unset the api dml status
106     Raise;
107 End update_dml;
108 --
109 -- ----------------------------------------------------------------------------
110 -- |------------------------------< pre_update >------------------------------|
111 -- ----------------------------------------------------------------------------
112 -- {Start Of Comments}
113 --
114 -- Description:
115 --   This private procedure contains any processing which is required before
116 --   the update dml.
117 --
118 -- Prerequisites:
119 --   This is an internal procedure which is called from the upd procedure.
120 --
121 -- In Parameters:
122 --   A Pl/Sql record structre.
123 --
124 -- Post Success:
125 --   Processing continues.
126 --
127 -- Post Failure:
128 --   If an error has occurred, an error message and exception will be raised
129 --   but not handled.
130 --
131 -- Developer Implementation Notes:
132 --   Any pre-processing required before the update dml is issued should be
133 --   coded within this procedure. It is important to note that any 3rd party
134 --   maintenance should be reviewed before placing in this procedure.
135 --
136 -- Access Status:
137 --   Internal Row Handler Use Only.
138 --
139 -- {End Of Comments}
140 -- ----------------------------------------------------------------------------
141 Procedure pre_update(p_rec in ben_xcv_shd.g_rec_type) is
142 --
143   l_proc  varchar2(72) := g_package||'pre_update';
144 --
145 Begin
146   hr_utility.set_location('Entering:'||l_proc, 5);
147   --
148   hr_utility.set_location(' Leaving:'||l_proc, 10);
149 End pre_update;
150 --
151 -- ----------------------------------------------------------------------------
152 -- |-----------------------------< post_update >------------------------------|
153 -- ----------------------------------------------------------------------------
154 -- {Start Of Comments}
155 --
156 -- Description:
157 --   This private procedure contains any processing which is required after the
158 --   update dml.
159 --
160 -- Prerequisites:
161 --   This is an internal procedure which is called from the upd procedure.
162 --
163 -- In Parameters:
164 --   A Pl/Sql record structre.
165 --
166 -- Post Success:
167 --   Processing continues.
168 --
169 -- Post Failure:
170 --   If an error has occurred, an error message and exception will be raised
171 --   but not handled.
172 --
173 -- Developer Implementation Notes:
174 --   Any post-processing required after the update dml is issued should be
175 --   coded within this procedure. It is important to note that any 3rd party
176 --   maintenance should be reviewed before placing in this procedure.
177 --
178 -- Access Status:
179 --   Internal Row Handler Use Only.
180 --
181 -- {End Of Comments}
182 -- ----------------------------------------------------------------------------
183 Procedure post_update(p_rec in ben_xcv_shd.g_rec_type) is
184 --
185   l_proc  varchar2(72) := g_package||'post_update';
186 --
187 Begin
188   hr_utility.set_location('Entering:'||l_proc, 5);
189 --
190   --
191   -- Start of API User Hook for post_update.
192   --
193   begin
194     --
195     ben_xcv_rku.after_update
196       (
197   p_ext_crit_val_id               =>p_rec.ext_crit_val_id
198  ,p_val_1                         =>p_rec.val_1
199  ,p_val_2                         =>p_rec.val_2
200  ,p_ext_crit_typ_id               =>p_rec.ext_crit_typ_id
201  ,p_business_group_id             =>p_rec.business_group_id
202  ,p_ext_crit_bg_id                =>p_rec.ext_crit_bg_id
203  ,p_legislation_code              =>p_rec.legislation_code
204  ,p_object_version_number         =>p_rec.object_version_number
205  ,p_val_1_o                       =>ben_xcv_shd.g_old_rec.val_1
206  ,p_val_2_o                       =>ben_xcv_shd.g_old_rec.val_2
207  ,p_ext_crit_typ_id_o             =>ben_xcv_shd.g_old_rec.ext_crit_typ_id
208  ,p_business_group_id_o           =>ben_xcv_shd.g_old_rec.business_group_id
209  ,p_ext_crit_bg_id_o             =>ben_xcv_shd.g_old_rec.ext_crit_bg_id
210  ,p_legislation_code_o            =>ben_xcv_shd.g_old_rec.legislation_code
211  ,p_object_version_number_o       =>ben_xcv_shd.g_old_rec.object_version_number
212       );
213     --
214   exception
215     --
216     when hr_api.cannot_find_prog_unit then
217       --
218       hr_api.cannot_find_prog_unit_error
219         (p_module_name => 'ben_ext_crit_val'
220         ,p_hook_type   => 'AU');
221       --
222   end;
223   --
224   -- End of API User Hook for post_update.
225   --
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 structre.
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 conversion
263 --   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(p_rec in out nocopy ben_xcv_shd.g_rec_type) is
274 --
275   l_proc  varchar2(72) := g_package||'convert_defs';
276 --
277 Begin
278   --
279   hr_utility.set_location('Entering:'||l_proc, 5);
280   --
281   -- We must now examine each argument value in the
282   -- p_rec plsql record structure
283   -- to see if a system default is being used. If a system default
284   -- is being used then we must set to the 'current' argument value.
285   --
286   If (p_rec.val_1 = hr_api.g_varchar2) then
287     p_rec.val_1 :=
288     ben_xcv_shd.g_old_rec.val_1;
289   End If;
290   If (p_rec.val_2 = hr_api.g_varchar2) then
291     p_rec.val_2 :=
292     ben_xcv_shd.g_old_rec.val_2;
293   End If;
294   If (p_rec.ext_crit_typ_id = hr_api.g_number) then
295     p_rec.ext_crit_typ_id :=
296     ben_xcv_shd.g_old_rec.ext_crit_typ_id;
297   End If;
298   If (p_rec.business_group_id = hr_api.g_number) then
299     p_rec.business_group_id :=
300     ben_xcv_shd.g_old_rec.business_group_id;
301   End If;
302 
303   If (p_rec.ext_crit_bg_id = hr_api.g_number) then
304     p_rec.ext_crit_bg_id :=
305     ben_xcv_shd.g_old_rec.ext_crit_bg_id;
306   End If;
307 
308   If (p_rec.legislation_code = hr_api.g_varchar2) then
309     p_rec.legislation_code :=
310     ben_xcv_shd.g_old_rec.legislation_code;
311   End If;
312   --
313   hr_utility.set_location(' Leaving:'||l_proc, 10);
314 --
315 End convert_defs;
316 --
317 -- ----------------------------------------------------------------------------
318 -- |---------------------------------< upd >----------------------------------|
319 -- ----------------------------------------------------------------------------
320 Procedure upd
321   (
322   p_effective_date in date,
323   p_rec        in out nocopy ben_xcv_shd.g_rec_type
324   ) is
325 --
326   l_proc  varchar2(72) := g_package||'upd';
327 --
328 Begin
329   hr_utility.set_location('Entering:'||l_proc, 5);
330   --
331   -- We must lock the row which we need to update.
332   --
333   ben_xcv_shd.lck
334 	(
335 	p_rec.ext_crit_val_id,
336 	p_rec.object_version_number
337 	);
338   --
339   -- 1. During an update system defaults are used to determine if
340   --    arguments have been defaulted or not. We must therefore
341   --    derive the full record structure values to be updated.
342   --
343   -- 2. Call the supporting update validate operations.
344   --
345   convert_defs(p_rec);
346   ben_xcv_bus.update_validate(p_rec
347   ,p_effective_date);
348   --
349   -- Call the supporting pre-update operation
350   --
351   pre_update(p_rec);
352   --
353   -- Update the row.
354   --
355   update_dml(p_rec);
356   --
357   -- Call the supporting post-update operation
358   --
359   post_update(p_rec);
360 End upd;
361 --
362 -- ----------------------------------------------------------------------------
363 -- |---------------------------------< upd >----------------------------------|
364 -- ----------------------------------------------------------------------------
365 Procedure upd
366   (
367   p_effective_date in date,
368   p_ext_crit_val_id              in number,
369   p_val_1                        in varchar2         default hr_api.g_varchar2,
370   p_val_2                        in varchar2         default hr_api.g_varchar2,
371   p_ext_crit_typ_id              in number           default hr_api.g_number,
372   p_business_group_id            in number           default hr_api.g_number,
373   p_ext_crit_bg_id               in number           default hr_api.g_number,
374   p_legislation_code             in varchar2         default hr_api.g_varchar2,
375   p_last_update_date             in date             default hr_api.g_date,
376   p_creation_date                in date             default hr_api.g_date,
377   p_last_updated_by              in number           default hr_api.g_number,
378   p_last_update_login            in number           default hr_api.g_number,
379   p_created_by                   in number           default hr_api.g_number,
380   p_object_version_number        in out nocopy number
381   ) is
382 --
383   l_rec	  ben_xcv_shd.g_rec_type;
384   l_proc  varchar2(72) := g_package||'upd';
385 --
386 Begin
387   hr_utility.set_location('Entering:'||l_proc, 5);
388   --
389   -- Call conversion function to turn arguments into the
390   -- l_rec structure.
391   --
392   l_rec :=
393   ben_xcv_shd.convert_args
394   (
395   p_ext_crit_val_id,
396   p_val_1,
397   p_val_2,
398   p_ext_crit_typ_id,
399   p_business_group_id,
400   p_ext_crit_bg_id,
401   p_legislation_code,
402   p_last_update_date,
403   p_creation_date    ,
404   p_last_updated_by  ,
405   p_last_update_login,
406   p_created_by       ,
407   p_object_version_number
408   );
409   --
410   -- Having converted the arguments into the
411   -- plsql record structure we call the corresponding record
412   -- business process.
413   --
414   upd(p_effective_date,l_rec);
415   p_object_version_number := l_rec.object_version_number;
416   --
417   hr_utility.set_location(' Leaving:'||l_proc, 10);
418 End upd;
419 --
420 end ben_xcv_upd;