1 Package Body pqp_gda_upd as
2 /* $Header: pqgdarhi.pkb 120.0 2005/05/29 01:52 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqp_gda_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 pqp_gda_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 pqp_gap_daily_absences Row
69 --
70 update pqp_gap_daily_absences
71 set
72 gap_daily_absence_id = p_rec.gap_daily_absence_id
73 ,gap_absence_plan_id = p_rec.gap_absence_plan_id
74 ,absence_date = p_rec.absence_date
75 ,work_pattern_day_type = p_rec.work_pattern_day_type
76 ,level_of_entitlement = p_rec.level_of_entitlement
77 ,level_of_pay = p_rec.level_of_pay
78 ,duration = p_rec.duration
79 ,duration_in_hours = p_rec.duration_in_hours
80 ,working_days_per_week = p_rec.working_days_per_week
81 ,fte = p_rec.fte -- LG
82 ,object_version_number = p_rec.object_version_number
83 where gap_daily_absence_id = p_rec.gap_daily_absence_id;
84 --
85 --
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 --
93 pqp_gda_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 --
98 pqp_gda_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 --
103 pqp_gda_shd.constraint_error
104 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
105 When Others Then
106 --
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 structure.
124 --
125 -- Post Success:
126 -- Processing continues.
127 --
128 -- Post Failure:
129 -- If an error has occurred, an error message and exception wil 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
143 (p_rec in pqp_gda_shd.g_rec_type
144 ) 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
161 -- the 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 structure.
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
188 ,p_rec in pqp_gda_shd.g_rec_type
189 ) is
190 --
191 l_proc varchar2(72) := g_package||'post_update';
192 --
193 Begin
194 hr_utility.set_location('Entering:'||l_proc, 5);
195 begin
196 --
197 pqp_gda_rku.after_update
198 (p_effective_date => p_effective_date
199 ,p_gap_daily_absence_id
200 => p_rec.gap_daily_absence_id
201 ,p_gap_absence_plan_id
202 => p_rec.gap_absence_plan_id
203 ,p_absence_date
204 => p_rec.absence_date
205 ,p_work_pattern_day_type
206 => p_rec.work_pattern_day_type
207 ,p_level_of_entitlement
208 => p_rec.level_of_entitlement
209 ,p_level_of_pay
210 => p_rec.level_of_pay
211 ,p_duration
212 => p_rec.duration
213 ,p_duration_in_hours
214 => p_rec.duration_in_hours
215 ,p_working_days_per_week
216 => p_rec.working_days_per_week
217 ,p_fte -- LG
218 => p_rec.fte -- LG
219 ,p_object_version_number
220 => p_rec.object_version_number
221 ,p_gap_absence_plan_id_o
222 => pqp_gda_shd.g_old_rec.gap_absence_plan_id
223 ,p_absence_date_o
224 => pqp_gda_shd.g_old_rec.absence_date
225 ,p_work_pattern_day_type_o
226 => pqp_gda_shd.g_old_rec.work_pattern_day_type
227 ,p_level_of_entitlement_o
228 => pqp_gda_shd.g_old_rec.level_of_entitlement
229 ,p_level_of_pay_o
230 => pqp_gda_shd.g_old_rec.level_of_pay
231 ,p_duration_o
232 => pqp_gda_shd.g_old_rec.duration
233 ,p_duration_in_hours_o
234 => pqp_gda_shd.g_old_rec.duration_in_hours
235 ,p_working_days_per_week_o
236 => pqp_gda_shd.g_old_rec.working_days_per_week
237 ,p_fte_o -- LG
238 => pqp_gda_shd.g_old_rec.fte -- LG
239 ,p_object_version_number_o
240 => pqp_gda_shd.g_old_rec.object_version_number
241 );
242 --
243 exception
244 --
245 when hr_api.cannot_find_prog_unit then
246 --
247 hr_api.cannot_find_prog_unit_error
248 (p_module_name => 'PQP_GAP_DAILY_ABSENCES'
249 ,p_hook_type => 'AU');
250 --
251 end;
252 --
253 hr_utility.set_location(' Leaving:'||l_proc, 10);
254 End post_update;
255 --
256 -- ----------------------------------------------------------------------------
257 -- |-----------------------------< convert_defs >-----------------------------|
258 -- ----------------------------------------------------------------------------
259 -- {Start Of Comments}
260 --
261 -- Description:
262 -- The Convert_Defs procedure has one very important function:
263 -- It must return the record structure for the row with all system defaulted
264 -- values converted into its corresponding parameter value for update. When
265 -- we attempt to update a row through the Upd process , certain
266 -- parameters can be defaulted which enables flexibility in the calling of
267 -- the upd process (e.g. only attributes which need to be updated need to be
268 -- specified). For the upd process to determine which attributes
269 -- have NOT been specified we need to check if the parameter has a reserved
270 -- system default value. Therefore, for all parameters which have a
271 -- corresponding reserved system default mechanism specified we need to
272 -- check if a system default is being used. If a system default is being
273 -- used then we convert the defaulted value into its corresponding attribute
274 -- value held in the g_old_rec data structure.
275 --
276 -- Prerequisites:
277 -- This private function can only be called from the upd process.
278 --
279 -- In Parameters:
280 -- A Pl/Sql record structure.
281 --
282 -- Post Success:
283 -- The record structure will be returned with all system defaulted parameter
284 -- values converted into its current row attribute value.
285 --
286 -- Post Failure:
287 -- No direct error handling is required within this function. Any possible
288 -- errors within this procedure will be a PL/SQL value error due to
289 -- conversion of datatypes or data lengths.
290 --
291 -- Developer Implementation Notes:
292 -- None.
293 --
294 -- Access Status:
295 -- Internal Row Handler Use Only.
296 --
297 -- {End Of Comments}
298 -- ----------------------------------------------------------------------------
299 Procedure convert_defs
300 (p_rec in out nocopy pqp_gda_shd.g_rec_type
301 ) is
302 --
303 Begin
304 --
305 -- We must now examine each argument value in the
306 -- p_rec plsql record structure
307 -- to see if a system default is being used. If a system default
308 -- is being used then we must set to the 'current' argument value.
309 --
310 If (p_rec.gap_absence_plan_id = hr_api.g_number) then
311 p_rec.gap_absence_plan_id :=
312 pqp_gda_shd.g_old_rec.gap_absence_plan_id;
313 End If;
314 If (p_rec.absence_date = hr_api.g_date) then
315 p_rec.absence_date :=
316 pqp_gda_shd.g_old_rec.absence_date;
317 End If;
318 If (p_rec.work_pattern_day_type = hr_api.g_varchar2) then
319 p_rec.work_pattern_day_type :=
320 pqp_gda_shd.g_old_rec.work_pattern_day_type;
321 End If;
322 If (p_rec.level_of_entitlement = hr_api.g_varchar2) then
323 p_rec.level_of_entitlement :=
324 pqp_gda_shd.g_old_rec.level_of_entitlement;
325 End If;
326 If (p_rec.level_of_pay = hr_api.g_varchar2) then
327 p_rec.level_of_pay :=
328 pqp_gda_shd.g_old_rec.level_of_pay;
329 End If;
330 If (p_rec.duration = hr_api.g_number) then
331 p_rec.duration :=
332 pqp_gda_shd.g_old_rec.duration;
333 End If;
334 If (p_rec.duration_in_hours = hr_api.g_number) then
335 p_rec.duration_in_hours :=
336 pqp_gda_shd.g_old_rec.duration_in_hours;
337 End If;
338 If (p_rec.working_days_per_week = hr_api.g_number) then
339 p_rec.working_days_per_week :=
340 pqp_gda_shd.g_old_rec.working_days_per_week;
341 End If;
342 -- LG added below if block
343 If (p_rec.fte = hr_api.g_number) then
344 p_rec.fte :=
345 pqp_gda_shd.g_old_rec.fte;
346 End If;
347 --
348 End convert_defs;
349 --
350 -- ----------------------------------------------------------------------------
351 -- |---------------------------------< upd >----------------------------------|
352 -- ----------------------------------------------------------------------------
353 Procedure upd
354 (p_effective_date in date
355 ,p_rec in out nocopy pqp_gda_shd.g_rec_type
356 ) is
357 --
358 l_proc varchar2(72) := g_package||'upd';
359 --
360 Begin
361 hr_utility.set_location('Entering:'||l_proc, 5);
362 --
363 -- We must lock the row which we need to update.
364 --
365 pqp_gda_shd.lck
366 (p_rec.gap_daily_absence_id
367 ,p_rec.object_version_number
368 );
369 --
370 -- 1. During an update system defaults are used to determine if
371 -- arguments have been defaulted or not. We must therefore
372 -- derive the full record structure values to be updated.
373 --
374 -- 2. Call the supporting update validate operations.
375 --
376 convert_defs(p_rec);
377 pqp_gda_bus.update_validate
378 (p_effective_date
379 ,p_rec
380 );
381 --
382 -- Call to raise any errors on multi-message list
383 hr_multi_message.end_validation_set;
384 --
385 -- Call the supporting pre-update operation
386 --
387 pqp_gda_upd.pre_update(p_rec);
388 --
389 -- Update the row.
390 --
391 pqp_gda_upd.update_dml(p_rec);
392 --
393 -- Call the supporting post-update operation
394 --
395 pqp_gda_upd.post_update
396 (p_effective_date
397 ,p_rec
398 );
399 --
400 -- Call to raise any errors on multi-message list
401 hr_multi_message.end_validation_set;
402 End upd;
403 --
404 -- ----------------------------------------------------------------------------
405 -- |---------------------------------< upd >----------------------------------|
406 -- ----------------------------------------------------------------------------
407 Procedure upd
408 (p_effective_date in date
409 ,p_gap_daily_absence_id in number
410 ,p_object_version_number in out nocopy number
411 ,p_gap_absence_plan_id in number default hr_api.g_number
412 ,p_absence_date in date default hr_api.g_date
413 ,p_work_pattern_day_type in varchar2 default hr_api.g_varchar2
414 ,p_level_of_entitlement in varchar2 default hr_api.g_varchar2
415 ,p_level_of_pay in varchar2 default hr_api.g_varchar2
416 ,p_duration in number default hr_api.g_number
417 ,p_duration_in_hours in number default hr_api.g_number
418 ,p_working_days_per_week in number default hr_api.g_number
419 ,p_fte in number default hr_api.g_number -- LG
420 ) is
421 --
422 l_rec pqp_gda_shd.g_rec_type;
423 l_proc varchar2(72) := g_package||'upd';
424 --
425 Begin
426 hr_utility.set_location('Entering:'||l_proc, 5);
427 --
428 -- Call conversion function to turn arguments into the
429 -- l_rec structure.
430 --
431 l_rec :=
432 pqp_gda_shd.convert_args
433 (p_gap_daily_absence_id
434 ,p_gap_absence_plan_id
435 ,p_absence_date
436 ,p_work_pattern_day_type
437 ,p_level_of_entitlement
438 ,p_level_of_pay
439 ,p_duration
440 ,p_duration_in_hours
441 ,p_working_days_per_week
442 ,p_fte -- LG
443 ,p_object_version_number
444 );
445 --
446 -- Having converted the arguments into the
447 -- plsql record structure we call the corresponding record
448 -- business process.
449 --
450 pqp_gda_upd.upd
451 (p_effective_date
452 ,l_rec
453 );
454 p_object_version_number := l_rec.object_version_number;
455 --
456 hr_utility.set_location(' Leaving:'||l_proc, 10);
457 End upd;
458 --
459 end pqp_gda_upd;