1 Package Body ben_act_upd as
2 /* $Header: beactrhi.pkb 120.0 2005/05/28 00:20:33 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_act_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_act_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_act_shd.g_api_dml := true; -- Set the api dml status
66 --
67 -- Update the ben_person_actions Row
68 --
69 update ben_person_actions
70 set
71 person_action_id = p_rec.person_action_id,
72 person_id = p_rec.person_id,
73 ler_id = p_rec.ler_id,
74 benefit_action_id = p_rec.benefit_action_id,
75 action_status_cd = p_rec.action_status_cd,
76 chunk_number = p_rec.chunk_number,
77 object_version_number = p_rec.object_version_number
78 where person_action_id = p_rec.person_action_id;
79 --
80 ben_act_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_act_shd.g_api_dml := false; -- Unset the api dml status
88 ben_act_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_act_shd.g_api_dml := false; -- Unset the api dml status
93 ben_act_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_act_shd.g_api_dml := false; -- Unset the api dml status
98 ben_act_shd.constraint_error
99 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
100 When Others Then
101 ben_act_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_act_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_act_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_act_rku.after_update
193 (p_person_action_id => p_rec.person_action_id
194 ,p_person_id => p_rec.person_id
195 ,p_ler_id => p_rec.ler_id
196 ,p_benefit_action_id => p_rec.benefit_action_id
197 ,p_action_status_cd => p_rec.action_status_cd
198 ,p_chunk_number => p_rec.chunk_number
199 ,p_object_version_number => p_rec.object_version_number
200 ,p_effective_date => p_effective_date
201 ,p_person_id_o => ben_act_shd.g_old_rec.person_id
202 ,p_ler_id_o => ben_act_shd.g_old_rec.ler_id
203 ,p_benefit_action_id_o => ben_act_shd.g_old_rec.benefit_action_id
204 ,p_action_status_cd_o => ben_act_shd.g_old_rec.action_status_cd
205 ,p_chunk_number_o => ben_act_shd.g_old_rec.chunk_number
206 ,p_object_version_number_o => ben_act_shd.g_old_rec.object_version_number);
207 --
208 exception
209 --
210 when hr_api.cannot_find_prog_unit then
211 --
212 hr_api.cannot_find_prog_unit_error
213 (p_module_name => 'ben_person_actions'
214 ,p_hook_type => 'AU');
215 --
216 end;
217 --
218 -- End of API User Hook for post_update.
219 --
220 --
221 hr_utility.set_location(' Leaving:'||l_proc, 10);
222 End post_update;
223 --
224 -- ----------------------------------------------------------------------------
225 -- |-----------------------------< convert_defs >-----------------------------|
226 -- ----------------------------------------------------------------------------
227 -- {Start Of Comments}
228 --
229 -- Description:
230 -- The Convert_Defs procedure has one very important function:
231 -- It must return the record structure for the row with all system defaulted
232 -- values converted into its corresponding parameter value for update. When
233 -- we attempt to update a row through the Upd process , certain
234 -- parameters can be defaulted which enables flexibility in the calling of
235 -- the upd process (e.g. only attributes which need to be updated need to be
236 -- specified). For the upd process to determine which attributes
237 -- have NOT been specified we need to check if the parameter has a reserved
238 -- system default value. Therefore, for all parameters which have a
239 -- corresponding reserved system default mechanism specified we need to
240 -- check if a system default is being used. If a system default is being
241 -- used then we convert the defaulted value into its corresponding attribute
242 -- value held in the g_old_rec data structure.
243 --
244 -- Prerequisites:
245 -- This private function can only be called from the upd process.
246 --
247 -- In Parameters:
248 -- A Pl/Sql record structre.
249 --
250 -- Post Success:
251 -- The record structure will be returned with all system defaulted parameter
252 -- values converted into its current row attribute value.
253 --
254 -- Post Failure:
255 -- No direct error handling is required within this function. Any possible
256 -- errors within this procedure will be a PL/SQL value error due to conversion
257 -- of datatypes or data lengths.
258 --
259 -- Developer Implementation Notes:
260 -- None.
261 --
262 -- Access Status:
263 -- Internal Row Handler Use Only.
264 --
265 -- {End Of Comments}
266 -- ----------------------------------------------------------------------------
267 Procedure convert_defs(p_rec in out nocopy ben_act_shd.g_rec_type) is
268 --
269 l_proc varchar2(72) := g_package||'convert_defs';
270 --
271 Begin
272 --
273 hr_utility.set_location('Entering:'||l_proc, 5);
274 --
275 -- We must now examine each argument value in the
276 -- p_rec plsql record structure
277 -- to see if a system default is being used. If a system default
278 -- is being used then we must set to the 'current' argument value.
279 --
280 If (p_rec.person_id = hr_api.g_number) then
281 p_rec.person_id :=
282 ben_act_shd.g_old_rec.person_id;
283 End If;
284 If (p_rec.ler_id = hr_api.g_number) then
285 p_rec.ler_id :=
286 ben_act_shd.g_old_rec.ler_id;
287 End If;
288 If (p_rec.benefit_action_id = hr_api.g_number) then
289 p_rec.benefit_action_id :=
290 ben_act_shd.g_old_rec.benefit_action_id;
291 End If;
292 If (p_rec.action_status_cd = hr_api.g_varchar2) then
293 p_rec.action_status_cd :=
294 ben_act_shd.g_old_rec.action_status_cd;
295 End If;
296 If (p_rec.chunk_number = hr_api.g_number) then
297 p_rec.chunk_number :=
298 ben_act_shd.g_old_rec.chunk_number;
299 End If;
300
301 --
302 hr_utility.set_location(' Leaving:'||l_proc, 10);
303 --
304 End convert_defs;
305 --
306 -- ----------------------------------------------------------------------------
307 -- |---------------------------------< upd >----------------------------------|
308 -- ----------------------------------------------------------------------------
309 Procedure upd
310 (
311 p_effective_date in date,
312 p_rec in out nocopy ben_act_shd.g_rec_type
313 ) is
314 --
315 l_proc varchar2(72) := g_package||'upd';
316 --
317 Begin
318 hr_utility.set_location('Entering:'||l_proc, 5);
319 --
320 -- We must lock the row which we need to update.
321 --
322 ben_act_shd.lck
323 (
324 p_rec.person_action_id,
325 p_rec.object_version_number
326 );
327 --
328 -- 1. During an update system defaults are used to determine if
329 -- arguments have been defaulted or not. We must therefore
330 -- derive the full record structure values to be updated.
331 --
332 -- 2. Call the supporting update validate operations.
333 --
334 convert_defs(p_rec);
335 ben_act_bus.update_validate(p_rec
336 ,p_effective_date);
337 --
338 -- Call the supporting pre-update operation
339 --
340 pre_update(p_rec);
341 --
342 -- Update the row.
343 --
344 update_dml(p_rec);
345 --
346 -- Call the supporting post-update operation
347 --
348 post_update(p_effective_date,p_rec);
349 End upd;
350 --
351 -- ----------------------------------------------------------------------------
352 -- |---------------------------------< upd >----------------------------------|
353 -- ----------------------------------------------------------------------------
354 Procedure upd
355 (
356 p_effective_date in date,
357 p_person_action_id in number,
358 p_person_id in number default hr_api.g_number,
359 p_ler_id in number default hr_api.g_number,
360 p_benefit_action_id in number default hr_api.g_number,
361 p_action_status_cd in varchar2 default hr_api.g_varchar2,
362 p_chunk_number in number default hr_api.g_number,
363 p_object_version_number in out nocopy number
364 ) is
365 --
366 l_rec ben_act_shd.g_rec_type;
367 l_proc varchar2(72) := g_package||'upd';
368 --
369 Begin
370 hr_utility.set_location('Entering:'||l_proc, 5);
371 --
372 -- Call conversion function to turn arguments into the
373 -- l_rec structure.
374 --
375 l_rec :=
376 ben_act_shd.convert_args
377 (
378 p_person_action_id,
379 p_person_id,
380 p_ler_id,
381 p_benefit_action_id,
382 p_action_status_cd,
383 p_chunk_number,
384 p_object_version_number
385 );
386 --
387 -- Having converted the arguments into the
388 -- plsql record structure we call the corresponding record
389 -- business process.
390 --
391 upd(
392 p_effective_date,l_rec);
393 p_object_version_number := l_rec.object_version_number;
394 --
395 hr_utility.set_location(' Leaving:'||l_proc, 10);
396 End upd;
397 --
398 end ben_act_upd;