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