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