DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_XCC_UPD

Source


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