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