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