1 Package Body ben_bmi_upd as
2 /* $Header: bebmirhi.pkb 115.5 2002/12/09 12:38:22 lakrish ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_bmi_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_bmi_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_bmi_shd.g_api_dml := true; -- Set the api dml status
66 --
67 -- Update the ben_batch_commu_info Row
68 --
69 update ben_batch_commu_info
70 set
71 batch_commu_id = p_rec.batch_commu_id,
72 benefit_action_id = p_rec.benefit_action_id,
73 person_id = p_rec.person_id,
74 per_cm_id = p_rec.per_cm_id,
75 cm_typ_id = p_rec.cm_typ_id,
76 business_group_id = p_rec.business_group_id,
77 per_cm_prvdd_id = p_rec.per_cm_prvdd_id,
78 to_be_sent_dt = p_rec.to_be_sent_dt,
79 object_version_number = p_rec.object_version_number
80 where batch_commu_id = p_rec.batch_commu_id;
81 --
82 ben_bmi_shd.g_api_dml := false; -- Unset the api dml status
83 --
84 hr_utility.set_location(' Leaving:'||l_proc, 10);
85 --
86 Exception
87 When hr_api.check_integrity_violated Then
88 -- A check constraint has been violated
89 ben_bmi_shd.g_api_dml := false; -- Unset the api dml status
90 ben_bmi_shd.constraint_error
91 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
92 When hr_api.parent_integrity_violated Then
93 -- Parent integrity has been violated
94 ben_bmi_shd.g_api_dml := false; -- Unset the api dml status
95 ben_bmi_shd.constraint_error
96 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
97 When hr_api.unique_integrity_violated Then
98 -- Unique integrity has been violated
99 ben_bmi_shd.g_api_dml := false; -- Unset the api dml status
100 ben_bmi_shd.constraint_error
101 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
102 When Others Then
103 ben_bmi_shd.g_api_dml := false; -- Unset the api dml status
104 Raise;
105 End update_dml;
106 --
107 -- ----------------------------------------------------------------------------
108 -- |------------------------------< pre_update >------------------------------|
109 -- ----------------------------------------------------------------------------
110 -- {Start Of Comments}
111 --
112 -- Description:
113 -- This private procedure contains any processing which is required before
114 -- the update dml.
115 --
116 -- Prerequisites:
117 -- This is an internal procedure which is called from the upd procedure.
118 --
119 -- In Parameters:
120 -- A Pl/Sql record structre.
121 --
122 -- Post Success:
123 -- Processing continues.
124 --
125 -- Post Failure:
126 -- If an error has occurred, an error message and exception will be raised
127 -- but not handled.
128 --
129 -- Developer Implementation Notes:
130 -- Any pre-processing required before the update dml is issued should be
131 -- coded within this procedure. It is important to note that any 3rd party
132 -- maintenance should be reviewed before placing in this procedure.
133 --
134 -- Access Status:
135 -- Internal Row Handler Use Only.
136 --
137 -- {End Of Comments}
138 -- ----------------------------------------------------------------------------
139 Procedure pre_update(p_rec in ben_bmi_shd.g_rec_type) is
140 --
141 l_proc varchar2(72) := g_package||'pre_update';
142 --
143 Begin
144 hr_utility.set_location('Entering:'||l_proc, 5);
145 --
146 hr_utility.set_location(' Leaving:'||l_proc, 10);
147 End pre_update;
148 --
149 -- ----------------------------------------------------------------------------
150 -- |-----------------------------< post_update >------------------------------|
151 -- ----------------------------------------------------------------------------
152 -- {Start Of Comments}
153 --
154 -- Description:
155 -- This private procedure contains any processing which is required after the
156 -- update dml.
157 --
158 -- Prerequisites:
159 -- This is an internal procedure which is called from the upd procedure.
160 --
161 -- In Parameters:
162 -- A Pl/Sql record structre.
163 --
164 -- Post Success:
165 -- Processing continues.
166 --
167 -- Post Failure:
168 -- If an error has occurred, an error message and exception will be raised
169 -- but not handled.
170 --
171 -- Developer Implementation Notes:
172 -- Any post-processing required after the update dml is issued should be
173 -- coded within this procedure. It is important to note that any 3rd party
174 -- maintenance should be reviewed before placing in this procedure.
175 --
176 -- Access Status:
177 -- Internal Row Handler Use Only.
178 --
179 -- {End Of Comments}
180 -- ----------------------------------------------------------------------------
181 Procedure post_update(p_rec in ben_bmi_shd.g_rec_type) is
182 --
183 l_proc varchar2(72) := g_package||'post_update';
184 --
185 Begin
186 hr_utility.set_location('Entering:'||l_proc, 5);
187 --
188 --
189 -- Start of API User Hook for post_update.
190 --
191 begin
192 --
193 ben_bmi_rku.after_update
194 (
195 p_batch_commu_id =>p_rec.batch_commu_id
196 ,p_benefit_action_id =>p_rec.benefit_action_id
197 ,p_person_id =>p_rec.person_id
198 ,p_per_cm_id =>p_rec.per_cm_id
199 ,p_cm_typ_id =>p_rec.cm_typ_id
200 ,p_business_group_id =>p_rec.business_group_id
201 ,p_per_cm_prvdd_id =>p_rec.per_cm_prvdd_id
202 ,p_to_be_sent_dt =>p_rec.to_be_sent_dt
203 ,p_object_version_number =>p_rec.object_version_number
204 ,p_benefit_action_id_o =>ben_bmi_shd.g_old_rec.benefit_action_id
205 ,p_person_id_o =>ben_bmi_shd.g_old_rec.person_id
206 ,p_per_cm_id_o =>ben_bmi_shd.g_old_rec.per_cm_id
207 ,p_cm_typ_id_o =>ben_bmi_shd.g_old_rec.cm_typ_id
208 ,p_business_group_id_o =>ben_bmi_shd.g_old_rec.business_group_id
209 ,p_per_cm_prvdd_id_o =>ben_bmi_shd.g_old_rec.per_cm_prvdd_id
210 ,p_to_be_sent_dt_o =>ben_bmi_shd.g_old_rec.to_be_sent_dt
211 ,p_object_version_number_o =>ben_bmi_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_batch_commu_info'
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_bmi_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.benefit_action_id = hr_api.g_number) then
287 p_rec.benefit_action_id :=
288 ben_bmi_shd.g_old_rec.benefit_action_id;
289 End If;
290 If (p_rec.person_id = hr_api.g_number) then
291 p_rec.person_id :=
292 ben_bmi_shd.g_old_rec.person_id;
293 End If;
294 If (p_rec.per_cm_id = hr_api.g_number) then
295 p_rec.per_cm_id :=
296 ben_bmi_shd.g_old_rec.per_cm_id;
297 End If;
298 If (p_rec.cm_typ_id = hr_api.g_number) then
299 p_rec.cm_typ_id :=
300 ben_bmi_shd.g_old_rec.cm_typ_id;
301 End If;
302 If (p_rec.business_group_id = hr_api.g_number) then
303 p_rec.business_group_id :=
304 ben_bmi_shd.g_old_rec.business_group_id;
305 End If;
306 If (p_rec.per_cm_prvdd_id = hr_api.g_number) then
307 p_rec.per_cm_prvdd_id :=
308 ben_bmi_shd.g_old_rec.per_cm_prvdd_id;
309 End If;
310 If (p_rec.to_be_sent_dt = hr_api.g_date) then
311 p_rec.to_be_sent_dt :=
312 ben_bmi_shd.g_old_rec.to_be_sent_dt;
313 End If;
314
315 --
316 hr_utility.set_location(' Leaving:'||l_proc, 10);
317 --
318 End convert_defs;
319 --
320 -- ----------------------------------------------------------------------------
321 -- |---------------------------------< upd >----------------------------------|
322 -- ----------------------------------------------------------------------------
323 Procedure upd
324 (
325 p_rec in out nocopy ben_bmi_shd.g_rec_type
326 ) is
327 --
328 l_proc varchar2(72) := g_package||'upd';
329 --
330 Begin
331 hr_utility.set_location('Entering:'||l_proc, 5);
332 --
333 -- We must lock the row which we need to update.
334 --
335 ben_bmi_shd.lck
336 (
337 p_rec.batch_commu_id,
338 p_rec.object_version_number
339 );
340 --
341 -- 1. During an update system defaults are used to determine if
342 -- arguments have been defaulted or not. We must therefore
343 -- derive the full record structure values to be updated.
344 --
345 -- 2. Call the supporting update validate operations.
346 --
347 convert_defs(p_rec);
348 ben_bmi_bus.update_validate(p_rec);
349 --
350 -- Call the supporting pre-update operation
351 --
352 pre_update(p_rec);
353 --
354 -- Update the row.
355 --
356 update_dml(p_rec);
357 --
358 -- Call the supporting post-update operation
359 --
360 post_update(p_rec);
361 End upd;
362 --
363 -- ----------------------------------------------------------------------------
364 -- |---------------------------------< upd >----------------------------------|
365 -- ----------------------------------------------------------------------------
366 Procedure upd
367 (
368 p_batch_commu_id in number,
369 p_benefit_action_id in number default hr_api.g_number,
370 p_person_id in number default hr_api.g_number,
371 p_per_cm_id in number default hr_api.g_number,
372 p_cm_typ_id in number default hr_api.g_number,
373 p_business_group_id in number default hr_api.g_number,
374 p_per_cm_prvdd_id in number default hr_api.g_number,
375 p_to_be_sent_dt in date default hr_api.g_date,
376 p_object_version_number in out nocopy number
377 ) is
378 --
379 l_rec ben_bmi_shd.g_rec_type;
380 l_proc varchar2(72) := g_package||'upd';
381 --
382 Begin
383 hr_utility.set_location('Entering:'||l_proc, 5);
384 --
385 -- Call conversion function to turn arguments into the
386 -- l_rec structure.
387 --
388 l_rec :=
389 ben_bmi_shd.convert_args
390 (
391 p_batch_commu_id,
392 p_benefit_action_id,
393 p_person_id,
394 p_per_cm_id,
395 p_cm_typ_id,
396 p_business_group_id,
397 p_per_cm_prvdd_id,
398 p_to_be_sent_dt,
399 p_object_version_number
400 );
401 --
402 -- Having converted the arguments into the
403 -- plsql record structure we call the corresponding record
404 -- business process.
405 --
406 upd(l_rec);
407 p_object_version_number := l_rec.object_version_number;
408 --
409 hr_utility.set_location(' Leaving:'||l_proc, 10);
410 End upd;
411 --
412 end ben_bmi_upd;