DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_BCI_UPD

Source


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