1 Package Body ben_xrs_upd as
2 /* $Header: bexrsrhi.pkb 120.1 2005/06/08 14:21:35 tjesumic noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_xrs_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_xrs_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_xrs_shd.g_api_dml := true; -- Set the api dml status
66 --
67 -- Update the ben_ext_rslt Row
68 --
69 update ben_ext_rslt
70 set
71 ext_rslt_id = p_rec.ext_rslt_id,
72 run_strt_dt = p_rec.run_strt_dt,
73 run_end_dt = p_rec.run_end_dt,
74 ext_stat_cd = p_rec.ext_stat_cd,
75 tot_rec_num = p_rec.tot_rec_num,
76 tot_per_num = p_rec.tot_per_num,
77 tot_err_num = p_rec.tot_err_num,
78 eff_dt = p_rec.eff_dt,
79 ext_strt_dt = p_rec.ext_strt_dt,
80 ext_end_dt = p_rec.ext_end_dt,
81 output_name = p_rec.output_name,
82 drctry_name = p_rec.drctry_name,
83 ext_dfn_id = p_rec.ext_dfn_id,
84 business_group_id = p_rec.business_group_id,
85 program_application_id = p_rec.program_application_id,
86 program_id = p_rec.program_id,
87 program_update_date = p_rec.program_update_date,
88 request_id = p_rec.request_id,
89 output_type = p_rec.output_type,
90 xdo_template_id = p_rec.xdo_template_id,
91 object_version_number = p_rec.object_version_number
92 where ext_rslt_id = p_rec.ext_rslt_id;
93 --
94 ben_xrs_shd.g_api_dml := false; -- Unset the api dml status
95 --
96 hr_utility.set_location(' Leaving:'||l_proc, 10);
97 --
98 Exception
99 When hr_api.check_integrity_violated Then
100 -- A check constraint has been violated
101 ben_xrs_shd.g_api_dml := false; -- Unset the api dml status
102 ben_xrs_shd.constraint_error
103 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
104 When hr_api.parent_integrity_violated Then
105 -- Parent integrity has been violated
106 ben_xrs_shd.g_api_dml := false; -- Unset the api dml status
107 ben_xrs_shd.constraint_error
108 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
109 When hr_api.unique_integrity_violated Then
110 -- Unique integrity has been violated
111 ben_xrs_shd.g_api_dml := false; -- Unset the api dml status
112 ben_xrs_shd.constraint_error
113 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
114 When Others Then
115 ben_xrs_shd.g_api_dml := false; -- Unset the api dml status
116 Raise;
117 End update_dml;
118 --
119 -- ----------------------------------------------------------------------------
120 -- |------------------------------< pre_update >------------------------------|
121 -- ----------------------------------------------------------------------------
122 -- {Start Of Comments}
123 --
124 -- Description:
125 -- This private procedure contains any processing which is required before
126 -- the update dml.
127 --
128 -- Prerequisites:
129 -- This is an internal procedure which is called from the upd procedure.
130 --
131 -- In Parameters:
132 -- A Pl/Sql record structre.
133 --
134 -- Post Success:
135 -- Processing continues.
136 --
137 -- Post Failure:
138 -- If an error has occurred, an error message and exception will be raised
139 -- but not handled.
140 --
141 -- Developer Implementation Notes:
142 -- Any pre-processing required before the update dml is issued should be
143 -- coded within this procedure. It is important to note that any 3rd party
144 -- maintenance should be reviewed before placing in this procedure.
145 --
146 -- Access Status:
147 -- Internal Row Handler Use Only.
148 --
149 -- {End Of Comments}
150 -- ----------------------------------------------------------------------------
151 Procedure pre_update(p_rec in ben_xrs_shd.g_rec_type) is
152 --
153 l_proc varchar2(72) := g_package||'pre_update';
154 --
155 Begin
156 hr_utility.set_location('Entering:'||l_proc, 5);
157 --
158 hr_utility.set_location(' Leaving:'||l_proc, 10);
159 End pre_update;
160 --
161 -- ----------------------------------------------------------------------------
162 -- |-----------------------------< post_update >------------------------------|
163 -- ----------------------------------------------------------------------------
164 -- {Start Of Comments}
165 --
166 -- Description:
167 -- This private procedure contains any processing which is required after the
168 -- update dml.
169 --
170 -- Prerequisites:
171 -- This is an internal procedure which is called from the upd procedure.
172 --
173 -- In Parameters:
174 -- A Pl/Sql record structre.
175 --
176 -- Post Success:
177 -- Processing continues.
178 --
179 -- Post Failure:
180 -- If an error has occurred, an error message and exception will be raised
181 -- but not handled.
182 --
183 -- Developer Implementation Notes:
184 -- Any post-processing required after the update dml is issued should be
185 -- coded within this procedure. It is important to note that any 3rd party
186 -- maintenance should be reviewed before placing in this procedure.
187 --
188 -- Access Status:
189 -- Internal Row Handler Use Only.
190 --
191 -- {End Of Comments}
192 -- ----------------------------------------------------------------------------
193 Procedure post_update(
194 p_effective_date in date,p_rec in ben_xrs_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 --
202 -- Start of API User Hook for post_update.
203 --
204 begin
205 --
206 ben_xrs_rku.after_update
207 (
208 p_ext_rslt_id =>p_rec.ext_rslt_id
209 ,p_run_strt_dt =>p_rec.run_strt_dt
210 ,p_run_end_dt =>p_rec.run_end_dt
211 ,p_ext_stat_cd =>p_rec.ext_stat_cd
212 ,p_tot_rec_num =>p_rec.tot_rec_num
213 ,p_tot_per_num =>p_rec.tot_per_num
214 ,p_tot_err_num =>p_rec.tot_err_num
215 ,p_eff_dt =>p_rec.eff_dt
216 ,p_ext_strt_dt =>p_rec.ext_strt_dt
217 ,p_ext_end_dt =>p_rec.ext_end_dt
218 ,p_output_name =>p_rec.output_name
219 ,p_drctry_name =>p_rec.drctry_name
220 ,p_ext_dfn_id =>p_rec.ext_dfn_id
221 ,p_business_group_id =>p_rec.business_group_id
222 ,p_program_application_id =>p_rec.program_application_id
223 ,p_program_id =>p_rec.program_id
224 ,p_program_update_date =>p_rec.program_update_date
225 ,p_request_id =>p_rec.request_id
226 ,p_output_type =>p_rec.output_type
227 ,p_xdo_template_id =>p_rec.xdo_template_id
228 ,p_object_version_number =>p_rec.object_version_number
229 ,p_effective_date =>p_effective_date
230 ,p_run_strt_dt_o =>ben_xrs_shd.g_old_rec.run_strt_dt
231 ,p_run_end_dt_o =>ben_xrs_shd.g_old_rec.run_end_dt
232 ,p_ext_stat_cd_o =>ben_xrs_shd.g_old_rec.ext_stat_cd
233 ,p_tot_rec_num_o =>ben_xrs_shd.g_old_rec.tot_rec_num
234 ,p_tot_per_num_o =>ben_xrs_shd.g_old_rec.tot_per_num
235 ,p_tot_err_num_o =>ben_xrs_shd.g_old_rec.tot_err_num
236 ,p_eff_dt_o =>ben_xrs_shd.g_old_rec.eff_dt
237 ,p_ext_strt_dt_o =>ben_xrs_shd.g_old_rec.ext_strt_dt
238 ,p_ext_end_dt_o =>ben_xrs_shd.g_old_rec.ext_end_dt
239 ,p_output_name_o =>ben_xrs_shd.g_old_rec.output_name
240 ,p_drctry_name_o =>ben_xrs_shd.g_old_rec.drctry_name
241 ,p_ext_dfn_id_o =>ben_xrs_shd.g_old_rec.ext_dfn_id
242 ,p_business_group_id_o =>ben_xrs_shd.g_old_rec.business_group_id
243 ,p_program_application_id_o =>ben_xrs_shd.g_old_rec.program_application_id
244 ,p_program_id_o =>ben_xrs_shd.g_old_rec.program_id
245 ,p_program_update_date_o =>ben_xrs_shd.g_old_rec.program_update_date
246 ,p_request_id_o =>ben_xrs_shd.g_old_rec.request_id
247 ,p_output_type_o =>ben_xrs_shd.g_old_rec.output_type
248 ,p_xdo_template_id_o =>ben_xrs_shd.g_old_rec.xdo_template_id
249 ,p_object_version_number_o =>ben_xrs_shd.g_old_rec.object_version_number
250 );
251 --
252 exception
253 --
254 when hr_api.cannot_find_prog_unit then
255 --
256 hr_api.cannot_find_prog_unit_error
257 (p_module_name => 'ben_ext_rslt'
258 ,p_hook_type => 'AU');
259 --
260 end;
261 --
262 -- End of API User Hook for post_update.
263 --
264 --
265 hr_utility.set_location(' Leaving:'||l_proc, 10);
266 End post_update;
267 --
268 -- ----------------------------------------------------------------------------
269 -- |-----------------------------< convert_defs >-----------------------------|
270 -- ----------------------------------------------------------------------------
271 -- {Start Of Comments}
272 --
273 -- Description:
274 -- The Convert_Defs procedure has one very important function:
275 -- It must return the record structure for the row with all system defaulted
276 -- values converted into its corresponding parameter value for update. When
277 -- we attempt to update a row through the Upd process , certain
278 -- parameters can be defaulted which enables flexibility in the calling of
279 -- the upd process (e.g. only attributes which need to be updated need to be
280 -- specified). For the upd process to determine which attributes
281 -- have NOT been specified we need to check if the parameter has a reserved
282 -- system default value. Therefore, for all parameters which have a
283 -- corresponding reserved system default mechanism specified we need to
284 -- check if a system default is being used. If a system default is being
285 -- used then we convert the defaulted value into its corresponding attribute
286 -- value held in the g_old_rec data structure.
287 --
288 -- Prerequisites:
289 -- This private function can only be called from the upd process.
290 --
291 -- In Parameters:
292 -- A Pl/Sql record structre.
293 --
294 -- Post Success:
295 -- The record structure will be returned with all system defaulted parameter
296 -- values converted into its current row attribute value.
297 --
298 -- Post Failure:
299 -- No direct error handling is required within this function. Any possible
300 -- errors within this procedure will be a PL/SQL value error due to conversion
301 -- of datatypes or data lengths.
302 --
303 -- Developer Implementation Notes:
304 -- None.
305 --
306 -- Access Status:
307 -- Internal Row Handler Use Only.
308 --
309 -- {End Of Comments}
310 -- ----------------------------------------------------------------------------
311 Procedure convert_defs(p_rec in out nocopy ben_xrs_shd.g_rec_type) is
312 --
313 l_proc varchar2(72) := g_package||'convert_defs';
314 --
315 Begin
316 --
317 hr_utility.set_location('Entering:'||l_proc, 5);
318 --
319 -- We must now examine each argument value in the
320 -- p_rec plsql record structure
321 -- to see if a system default is being used. If a system default
322 -- is being used then we must set to the 'current' argument value.
323 --
324 If (p_rec.run_strt_dt = hr_api.g_date) then
325 p_rec.run_strt_dt :=
326 ben_xrs_shd.g_old_rec.run_strt_dt;
327 End If;
328 If (p_rec.run_end_dt = hr_api.g_date) then
329 p_rec.run_end_dt :=
330 ben_xrs_shd.g_old_rec.run_end_dt;
331 End If;
332 If (p_rec.ext_stat_cd = hr_api.g_varchar2) then
333 p_rec.ext_stat_cd :=
334 ben_xrs_shd.g_old_rec.ext_stat_cd;
335 End If;
336 If (p_rec.tot_rec_num = hr_api.g_number) then
337 p_rec.tot_rec_num :=
338 ben_xrs_shd.g_old_rec.tot_rec_num;
339 End If;
340 If (p_rec.tot_per_num = hr_api.g_number) then
341 p_rec.tot_per_num :=
342 ben_xrs_shd.g_old_rec.tot_per_num;
343 End If;
344 If (p_rec.tot_err_num = hr_api.g_number) then
345 p_rec.tot_err_num :=
346 ben_xrs_shd.g_old_rec.tot_err_num;
347 End If;
348 If (p_rec.eff_dt = hr_api.g_date) then
349 p_rec.eff_dt :=
350 ben_xrs_shd.g_old_rec.eff_dt;
351 End If;
352 If (p_rec.ext_strt_dt = hr_api.g_date) then
353 p_rec.ext_strt_dt :=
354 ben_xrs_shd.g_old_rec.ext_strt_dt;
355 End If;
356 If (p_rec.ext_end_dt = hr_api.g_date) then
357 p_rec.ext_end_dt :=
358 ben_xrs_shd.g_old_rec.ext_end_dt;
359 End If;
360 If (p_rec.output_name = hr_api.g_varchar2) then
361 p_rec.output_name :=
362 ben_xrs_shd.g_old_rec.output_name;
363 End If;
364 If (p_rec.drctry_name = hr_api.g_varchar2) then
365 p_rec.drctry_name :=
366 ben_xrs_shd.g_old_rec.drctry_name;
367 End If;
368 If (p_rec.ext_dfn_id = hr_api.g_number) then
369 p_rec.ext_dfn_id :=
370 ben_xrs_shd.g_old_rec.ext_dfn_id;
371 End If;
372 If (p_rec.business_group_id = hr_api.g_number) then
373 p_rec.business_group_id :=
374 ben_xrs_shd.g_old_rec.business_group_id;
375 End If;
376 If (p_rec.program_application_id = hr_api.g_number) then
377 p_rec.program_application_id :=
378 ben_xrs_shd.g_old_rec.program_application_id;
379 End If;
380 If (p_rec.program_id = hr_api.g_number) then
381 p_rec.program_id :=
382 ben_xrs_shd.g_old_rec.program_id;
383 End If;
384 If (p_rec.program_update_date = hr_api.g_date) then
385 p_rec.program_update_date :=
386 ben_xrs_shd.g_old_rec.program_update_date;
387 End If;
388 If (p_rec.request_id = hr_api.g_number) then
389 p_rec.request_id :=
390 ben_xrs_shd.g_old_rec.request_id;
391 End If;
392
393 If (p_rec.output_type = hr_api.g_varchar2) then
394 p_rec.output_type :=
395 ben_xrs_shd.g_old_rec.output_type;
396 End If;
397
398
399 if (p_rec.xdo_template_id = hr_api.g_number) then
400 p_rec.xdo_template_id :=
401 ben_xrs_shd.g_old_rec.xdo_template_id;
402 End If;
403 --
404 hr_utility.set_location(' Leaving:'||l_proc, 10);
405 --
406 End convert_defs;
407 --
408 -- ----------------------------------------------------------------------------
409 -- |---------------------------------< upd >----------------------------------|
410 -- ----------------------------------------------------------------------------
411 Procedure upd
412 (
413 p_effective_date in date,
414 p_rec in out nocopy ben_xrs_shd.g_rec_type
415 ) is
416 --
417 l_proc varchar2(72) := g_package||'upd';
418 --
419 Begin
420 hr_utility.set_location('Entering:'||l_proc, 5);
421 --
422 -- We must lock the row which we need to update.
423 --
424 ben_xrs_shd.lck
425 (
426 p_rec.ext_rslt_id,
427 p_rec.object_version_number
428 );
429 --
430 -- 1. During an update system defaults are used to determine if
431 -- arguments have been defaulted or not. We must therefore
432 -- derive the full record structure values to be updated.
433 --
434 -- 2. Call the supporting update validate operations.
435 --
436 convert_defs(p_rec);
437 ben_xrs_bus.update_validate(p_rec
438 ,p_effective_date);
439 --
440 -- Call the supporting pre-update operation
441 --
442 pre_update(p_rec);
443 --
444 -- Update the row.
445 --
446 update_dml(p_rec);
447 --
448 -- Call the supporting post-update operation
449 --
450 post_update(
451 p_effective_date,p_rec);
452 End upd;
453 --
454 -- ----------------------------------------------------------------------------
455 -- |---------------------------------< upd >----------------------------------|
456 -- ----------------------------------------------------------------------------
457 Procedure upd
458 (
459 p_effective_date in date,
460 p_ext_rslt_id in number,
461 p_run_strt_dt in date default hr_api.g_date,
462 p_run_end_dt in date default hr_api.g_date,
463 p_ext_stat_cd in varchar2 default hr_api.g_varchar2,
464 p_tot_rec_num in number default hr_api.g_number,
465 p_tot_per_num in number default hr_api.g_number,
466 p_tot_err_num in number default hr_api.g_number,
467 p_eff_dt in date default hr_api.g_date,
468 p_ext_strt_dt in date default hr_api.g_date,
469 p_ext_end_dt in date default hr_api.g_date,
470 p_output_name in varchar2 default hr_api.g_varchar2,
471 p_drctry_name in varchar2 default hr_api.g_varchar2,
472 p_ext_dfn_id in number default hr_api.g_number,
473 p_business_group_id in number default hr_api.g_number,
474 p_program_application_id in number default hr_api.g_number,
475 p_program_id in number default hr_api.g_number,
476 p_program_update_date in date default hr_api.g_date,
477 p_request_id in number default hr_api.g_number,
478 p_output_type in varchar2 default hr_api.g_varchar2,
479 p_xdo_template_id in number default hr_api.g_number,
480 p_object_version_number in out nocopy number
481 ) is
482 --
483 l_rec ben_xrs_shd.g_rec_type;
484 l_proc varchar2(72) := g_package||'upd';
485 --
486 Begin
487 hr_utility.set_location('Entering:'||l_proc, 5);
488 --
489 -- Call conversion function to turn arguments into the
490 -- l_rec structure.
491 --
492 l_rec :=
493 ben_xrs_shd.convert_args
494 (
495 p_ext_rslt_id,
496 p_run_strt_dt,
497 p_run_end_dt,
498 p_ext_stat_cd,
499 p_tot_rec_num,
500 p_tot_per_num,
501 p_tot_err_num,
502 p_eff_dt,
503 p_ext_strt_dt,
504 p_ext_end_dt,
505 p_output_name,
506 p_drctry_name,
507 p_ext_dfn_id,
508 p_business_group_id,
509 p_program_application_id,
510 p_program_id,
511 p_program_update_date,
512 p_request_id,
513 p_output_type,
514 p_xdo_template_id ,
515 p_object_version_number
516 );
517 --
518 -- Having converted the arguments into the
519 -- plsql record structure we call the corresponding record
520 -- business process.
521 --
522 upd(
523 p_effective_date,l_rec);
524 p_object_version_number := l_rec.object_version_number;
525 --
526 hr_utility.set_location(' Leaving:'||l_proc, 10);
527 End upd;
528 --
529 end ben_xrs_upd;