1 Package Body ben_xre_upd as
2 /* $Header: bexrerhi.pkb 115.8 2002/12/16 17:41:12 glingapp ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_xre_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_xre_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_xre_shd.g_api_dml := true; -- Set the api dml status
66 --
67 -- Update the ben_ext_rslt_err Row
68 --
69 update ben_ext_rslt_err
70 set
71 ext_rslt_err_id = p_rec.ext_rslt_err_id,
72 err_num = p_rec.err_num,
73 err_txt = p_rec.err_txt,
74 typ_cd = p_rec.typ_cd,
75 person_id = p_rec.person_id,
76 business_group_id = p_rec.business_group_id,
77 object_version_number = p_rec.object_version_number,
78 request_id = p_rec.request_id,
79 program_application_id = p_rec.program_application_id,
80 program_id = p_rec.program_id,
81 program_update_date = p_rec.program_update_date,
82 ext_rslt_id = p_rec.ext_rslt_id
83 where ext_rslt_err_id = p_rec.ext_rslt_err_id;
84 --
85 ben_xre_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_xre_shd.g_api_dml := false; -- Unset the api dml status
93 ben_xre_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_xre_shd.g_api_dml := false; -- Unset the api dml status
98 ben_xre_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_xre_shd.g_api_dml := false; -- Unset the api dml status
103 ben_xre_shd.constraint_error
104 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
105 When Others Then
106 ben_xre_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_xre_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_xre_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_xre_rku.after_update
198 (
199 p_ext_rslt_err_id =>p_rec.ext_rslt_err_id
200 ,p_err_num =>p_rec.err_num
201 ,p_err_txt =>p_rec.err_txt
202 ,p_typ_cd =>p_rec.typ_cd
203 ,p_person_id =>p_rec.person_id
204 ,p_business_group_id =>p_rec.business_group_id
205 ,p_object_version_number =>p_rec.object_version_number
206 ,p_request_id =>p_rec.request_id
207 ,p_program_application_id =>p_rec.program_application_id
208 ,p_program_id =>p_rec.program_id
209 ,p_program_update_date =>p_rec.program_update_date
210 ,p_ext_rslt_id =>p_rec.ext_rslt_id
211 ,p_effective_date =>p_effective_date
212 ,p_err_num_o =>ben_xre_shd.g_old_rec.err_num
213 ,p_err_txt_o =>ben_xre_shd.g_old_rec.err_txt
214 ,p_typ_cd_o =>ben_xre_shd.g_old_rec.typ_cd
215 ,p_person_id_o =>ben_xre_shd.g_old_rec.person_id
216 ,p_business_group_id_o =>ben_xre_shd.g_old_rec.business_group_id
217 ,p_object_version_number_o =>ben_xre_shd.g_old_rec.object_version_number
218 ,p_request_id_o =>ben_xre_shd.g_old_rec.request_id
219 ,p_program_application_id_o =>ben_xre_shd.g_old_rec.program_application_id
220 ,p_program_id_o =>ben_xre_shd.g_old_rec.program_id
221 ,p_program_update_date_o =>ben_xre_shd.g_old_rec.program_update_date
222 ,p_ext_rslt_id_o =>ben_xre_shd.g_old_rec.ext_rslt_id
223 );
224 --
225 exception
226 --
227 when hr_api.cannot_find_prog_unit then
228 --
229 hr_api.cannot_find_prog_unit_error
230 (p_module_name => 'ben_ext_rslt_err'
231 ,p_hook_type => 'AU');
232 --
233 end;
234 --
235 -- End of API User Hook for post_update.
236 --
237 --
238 hr_utility.set_location(' Leaving:'||l_proc, 10);
239 End post_update;
240 --
241 -- ----------------------------------------------------------------------------
242 -- |-----------------------------< convert_defs >-----------------------------|
243 -- ----------------------------------------------------------------------------
244 -- {Start Of Comments}
245 --
246 -- Description:
247 -- The Convert_Defs procedure has one very important function:
248 -- It must return the record structure for the row with all system defaulted
249 -- values converted into its corresponding parameter value for update. When
250 -- we attempt to update a row through the Upd process , certain
251 -- parameters can be defaulted which enables flexibility in the calling of
252 -- the upd process (e.g. only attributes which need to be updated need to be
253 -- specified). For the upd process to determine which attributes
254 -- have NOT been specified we need to check if the parameter has a reserved
255 -- system default value. Therefore, for all parameters which have a
256 -- corresponding reserved system default mechanism specified we need to
257 -- check if a system default is being used. If a system default is being
258 -- used then we convert the defaulted value into its corresponding attribute
259 -- value held in the g_old_rec data structure.
260 --
261 -- Prerequisites:
262 -- This private function can only be called from the upd process.
263 --
264 -- In Parameters:
265 -- A Pl/Sql record structre.
266 --
267 -- Post Success:
268 -- The record structure will be returned with all system defaulted parameter
269 -- values converted into its current row attribute value.
270 --
271 -- Post Failure:
272 -- No direct error handling is required within this function. Any possible
273 -- errors within this procedure will be a PL/SQL value error due to conversion
274 -- of datatypes or data lengths.
275 --
276 -- Developer Implementation Notes:
277 -- None.
278 --
279 -- Access Status:
280 -- Internal Row Handler Use Only.
281 --
282 -- {End Of Comments}
283 -- ----------------------------------------------------------------------------
284 Procedure convert_defs(p_rec in out nocopy ben_xre_shd.g_rec_type) is
285 --
286 l_proc varchar2(72) := g_package||'convert_defs';
287 --
288 Begin
289 --
290 hr_utility.set_location('Entering:'||l_proc, 5);
291 --
292 -- We must now examine each argument value in the
293 -- p_rec plsql record structure
294 -- to see if a system default is being used. If a system default
295 -- is being used then we must set to the 'current' argument value.
296 --
297 If (p_rec.err_num = hr_api.g_number) then
298 p_rec.err_num :=
299 ben_xre_shd.g_old_rec.err_num;
300 End If;
301 If (p_rec.err_txt = hr_api.g_varchar2) then
302 p_rec.err_txt :=
303 ben_xre_shd.g_old_rec.err_txt;
304 End If;
305 If (p_rec.typ_cd = hr_api.g_varchar2) then
306 p_rec.typ_cd :=
307 ben_xre_shd.g_old_rec.typ_cd;
308 End If;
309 If (p_rec.person_id = hr_api.g_number) then
310 p_rec.person_id :=
311 ben_xre_shd.g_old_rec.person_id;
312 End If;
313 If (p_rec.business_group_id = hr_api.g_number) then
314 p_rec.business_group_id :=
315 ben_xre_shd.g_old_rec.business_group_id;
316 End If;
317 If (p_rec.request_id = hr_api.g_number) then
318 p_rec.request_id :=
319 ben_xre_shd.g_old_rec.request_id;
320 End If;
321 If (p_rec.program_application_id = hr_api.g_number) then
322 p_rec.program_application_id :=
323 ben_xre_shd.g_old_rec.program_application_id;
324 End If;
325 If (p_rec.program_id = hr_api.g_number) then
326 p_rec.program_id :=
327 ben_xre_shd.g_old_rec.program_id;
328 End If;
329 If (p_rec.program_update_date = hr_api.g_date) then
330 p_rec.program_update_date :=
331 ben_xre_shd.g_old_rec.program_update_date;
332 End If;
333 If (p_rec.ext_rslt_id = hr_api.g_number) then
334 p_rec.ext_rslt_id :=
335 ben_xre_shd.g_old_rec.ext_rslt_id;
336 End If;
337 --
338 hr_utility.set_location(' Leaving:'||l_proc, 10);
339 --
340 End convert_defs;
341 --
342 -- ----------------------------------------------------------------------------
343 -- |---------------------------------< upd >----------------------------------|
344 -- ----------------------------------------------------------------------------
345 Procedure upd
346 (
347 p_effective_date in date,
348 p_rec in out nocopy ben_xre_shd.g_rec_type
349 ) is
350 --
351 l_proc varchar2(72) := g_package||'upd';
352 --
353 Begin
354 hr_utility.set_location('Entering:'||l_proc, 5);
355 --
356 -- We must lock the row which we need to update.
357 --
358 ben_xre_shd.lck
359 (
360 p_rec.ext_rslt_err_id,
361 p_rec.object_version_number
362 );
363 --
364 -- 1. During an update system defaults are used to determine if
365 -- arguments have been defaulted or not. We must therefore
366 -- derive the full record structure values to be updated.
367 --
368 -- 2. Call the supporting update validate operations.
369 --
370 convert_defs(p_rec);
371 ben_xre_bus.update_validate(p_rec
372 ,p_effective_date);
373 --
374 -- Call the supporting pre-update operation
375 --
376 pre_update(p_rec);
377 --
378 -- Update the row.
379 --
380 update_dml(p_rec);
381 --
382 -- Call the supporting post-update operation
383 --
384 post_update(
385 p_effective_date,p_rec);
386 End upd;
387 --
388 -- ----------------------------------------------------------------------------
389 -- |---------------------------------< upd >----------------------------------|
390 -- ----------------------------------------------------------------------------
391 Procedure upd
392 (
393 p_effective_date in date,
394 p_ext_rslt_err_id in number,
395 p_err_num in number default hr_api.g_number,
396 p_err_txt in varchar2 default hr_api.g_varchar2,
397 p_typ_cd in varchar2 default hr_api.g_varchar2,
398 p_person_id in number default hr_api.g_number,
399 p_business_group_id in number default hr_api.g_number,
400 p_object_version_number in out nocopy number,
401 p_request_id in number default hr_api.g_number,
402 p_program_application_id in number default hr_api.g_number,
403 p_program_id in number default hr_api.g_number,
404 p_program_update_date in date default hr_api.g_date,
405 p_ext_rslt_id in number default hr_api.g_number
406 ) is
407 --
408 l_rec ben_xre_shd.g_rec_type;
409 l_proc varchar2(72) := g_package||'upd';
410 --
411 Begin
412 hr_utility.set_location('Entering:'||l_proc, 5);
413 --
414 -- Call conversion function to turn arguments into the
415 -- l_rec structure.
416 --
417 l_rec :=
418 ben_xre_shd.convert_args
419 (
420 p_ext_rslt_err_id,
421 p_err_num,
422 p_err_txt,
423 p_typ_cd,
424 p_person_id,
425 p_business_group_id,
426 p_object_version_number,
427 p_request_id,
428 p_program_application_id,
429 p_program_id,
430 p_program_update_date,
431 p_ext_rslt_id
432 );
433 --
434 -- Having converted the arguments into the
435 -- plsql record structure we call the corresponding record
436 -- business process.
437 --
438 upd(
439 p_effective_date,l_rec);
440 p_object_version_number := l_rec.object_version_number;
441 --
442 hr_utility.set_location(' Leaving:'||l_proc, 10);
443 End upd;
444 --
445 end ben_xre_upd;