1 Package Body pqh_str_upd as
2 /* $Header: pqstrrhi.pkb 115.10 2004/04/06 05:49 svorugan noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_str_upd.'; -- Global package name
9
10 g_debug boolean := hr_utility.debug_enabled;
11
12 --
13 -- ----------------------------------------------------------------------------
14 -- |------------------------------< update_dml >------------------------------|
15 -- ----------------------------------------------------------------------------
16 -- {Start Of Comments}
17 --
18 -- Description:
19 -- This procedure controls the actual dml update logic. The processing of
20 -- this procedure is:
21 -- 1) Increment the object_version_number by 1 if the object_version_number
22 -- is defined as an attribute for this entity.
23 -- 2) To set and unset the g_api_dml status as required (as we are about to
24 -- perform dml).
25 -- 3) To update the specified row in the schema using the primary key in
26 -- the predicates.
27 -- 4) To trap any constraint violations that may have occurred.
28 -- 5) To raise any other errors.
29 --
30 -- Prerequisites:
31 -- This is an internal private procedure which must be called from the upd
32 -- procedure.
33 --
34 -- In Parameters:
35 -- A Pl/Sql record structre.
36 --
37 -- Post Success:
38 -- The specified row will be updated in the schema.
39 --
40 -- Post Failure:
41 -- On the update dml failure it is important to note that we always reset the
42 -- g_api_dml status to false.
43 -- If a check, unique or parent integrity constraint violation is raised the
44 -- constraint_error procedure will be called.
45 -- If any other error is reported, the error will be raised after the
46 -- g_api_dml status is reset.
47 --
48 -- Developer Implementation Notes:
49 -- The update 'set' attribute list should be modified if any of your
50 -- attributes are not updateable.
51 --
52 -- Access Status:
53 -- Internal Row Handler Use Only.
54 --
55 -- {End Of Comments}
56 -- ----------------------------------------------------------------------------
57 Procedure update_dml
58 (p_rec in out nocopy pqh_str_shd.g_rec_type
59 ) is
60 --
61 l_proc varchar2(72) := g_package||'update_dml';
62 --
63 Begin
64
65 if g_debug then
66 --
67 hr_utility.set_location('Entering:'||l_proc, 5);
68 --
69 End if;
70
71 --
72 -- Increment the object version
73 p_rec.object_version_number := p_rec.object_version_number + 1;
74 --
75 --
76 --
77 -- Update the pqh_fr_stat_situation_rules Row
78 --
79 update pqh_fr_stat_situation_rules
80 set
81 stat_situation_rule_id = p_rec.stat_situation_rule_id
82 ,statutory_situation_id = p_rec.statutory_situation_id
83 ,processing_sequence = p_rec.processing_sequence
84 ,txn_category_attribute_id = p_rec.txn_category_attribute_id
85 ,from_value = p_rec.from_value
86 ,to_value = p_rec.to_value
87 ,enabled_flag = p_rec.enabled_flag
88 ,required_flag = p_rec.required_flag
89 ,exclude_flag = p_rec.exclude_flag
90 ,object_version_number = p_rec.object_version_number
91 where stat_situation_rule_id = p_rec.stat_situation_rule_id;
92 --
93 --
94 --
95 if g_debug then
96 --
97 hr_utility.set_location(' Leaving:'||l_proc, 10);
98 --
99 End if;
100
101 --
102 Exception
103 When hr_api.check_integrity_violated Then
104 -- A check constraint has been violated
105 --
106 pqh_str_shd.constraint_error
107 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
108 When hr_api.parent_integrity_violated Then
109 -- Parent integrity has been violated
110 --
111 pqh_str_shd.constraint_error
112 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
113 When hr_api.unique_integrity_violated Then
114 -- Unique integrity has been violated
115 --
116 pqh_str_shd.constraint_error
117 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
118 When Others Then
119 --
120 Raise;
121 End update_dml;
122 --
123 -- ----------------------------------------------------------------------------
124 -- |------------------------------< pre_update >------------------------------|
125 -- ----------------------------------------------------------------------------
126 -- {Start Of Comments}
127 --
128 -- Description:
129 -- This private procedure contains any processing which is required before
130 -- the update dml.
131 --
132 -- Prerequisites:
133 -- This is an internal procedure which is called from the upd procedure.
134 --
135 -- In Parameters:
136 -- A Pl/Sql record structure.
137 --
138 -- Post Success:
139 -- Processing continues.
140 --
141 -- Post Failure:
142 -- If an error has occurred, an error message and exception wil be raised
143 -- but not handled.
144 --
145 -- Developer Implementation Notes:
146 -- Any pre-processing required before the update dml is issued should be
147 -- coded within this procedure. It is important to note that any 3rd party
148 -- maintenance should be reviewed before placing in this procedure.
149 --
150 -- Access Status:
151 -- Internal Row Handler Use Only.
152 --
153 -- {End Of Comments}
154 -- ----------------------------------------------------------------------------
155 Procedure pre_update
156 (p_rec in pqh_str_shd.g_rec_type
157 ) is
158 --
159 l_proc varchar2(72) := g_package||'pre_update';
160 --
161 Begin
162 if g_debug then
163 --
164 hr_utility.set_location('Entering:'||l_proc, 5);
165 --
166 End if;
167
168 --
169 if g_debug then
170 --
171 hr_utility.set_location(' Leaving:'||l_proc, 10);
172 --
173 End if;
174
175
176 End pre_update;
177 --
178 -- ----------------------------------------------------------------------------
179 -- |-----------------------------< post_update >------------------------------|
180 -- ----------------------------------------------------------------------------
181 -- {Start Of Comments}
182 --
183 -- Description:
184 -- This private procedure contains any processing which is required after
185 -- the update dml.
186 --
187 -- Prerequisites:
188 -- This is an internal procedure which is called from the upd procedure.
189 --
190 -- In Parameters:
191 -- A Pl/Sql record structure.
192 --
193 -- Post Success:
194 -- Processing continues.
195 --
196 -- Post Failure:
197 -- If an error has occurred, an error message and exception will be raised
198 -- but not handled.
199 --
200 -- Developer Implementation Notes:
201 -- Any post-processing required after the update dml is issued should be
202 -- coded within this procedure. It is important to note that any 3rd party
203 -- maintenance should be reviewed before placing in this procedure.
204 --
205 -- Access Status:
206 -- Internal Row Handler Use Only.
207 --
208 -- {End Of Comments}
209 -- ----------------------------------------------------------------------------
210 Procedure post_update
211 (p_effective_date in date
212 ,p_rec in pqh_str_shd.g_rec_type
213 ) is
214 --
215 l_proc varchar2(72) := g_package||'post_update';
216 --
217 Begin
218
219 if g_debug then
220 --
221 hr_utility.set_location('Entering:'||l_proc, 5);
222 --
223 End if;
224
225 begin
226 --
227 pqh_str_rku.after_update
228 (p_effective_date => p_effective_date
229 ,p_stat_situation_rule_id
230 => p_rec.stat_situation_rule_id
231 ,p_statutory_situation_id
232 => p_rec.statutory_situation_id
233 ,p_processing_sequence
234 => p_rec.processing_sequence
235 ,p_txn_category_attribute_id
236 => p_rec.txn_category_attribute_id
237 ,p_from_value
238 => p_rec.from_value
239 ,p_to_value
240 => p_rec.to_value
241 ,p_enabled_flag
242 => p_rec.enabled_flag
243 ,p_required_flag
244 => p_rec.required_flag
245 ,p_exclude_flag
246 => p_rec.exclude_flag
247 ,p_object_version_number
248 => p_rec.object_version_number
249 ,p_statutory_situation_id_o
250 => pqh_str_shd.g_old_rec.statutory_situation_id
251 ,p_processing_sequence_o
252 => pqh_str_shd.g_old_rec.processing_sequence
253 ,p_txn_category_attribute_id_o
254 => pqh_str_shd.g_old_rec.txn_category_attribute_id
255 ,p_from_value_o
256 => pqh_str_shd.g_old_rec.from_value
257 ,p_to_value_o
258 => pqh_str_shd.g_old_rec.to_value
259 ,p_enabled_flag_o
260 => pqh_str_shd.g_old_rec.enabled_flag
261 ,p_required_flag_o
262 => pqh_str_shd.g_old_rec.required_flag
263 ,p_exclude_flag_o
264 => pqh_str_shd.g_old_rec.exclude_flag
265 ,p_object_version_number_o
266 => pqh_str_shd.g_old_rec.object_version_number
267 );
268 --
269 exception
270 --
271 when hr_api.cannot_find_prog_unit then
272 --
273 hr_api.cannot_find_prog_unit_error
274 (p_module_name => 'PQH_FR_STAT_SITUATION_RULES'
275 ,p_hook_type => 'AU');
276 --
277 end;
278 --
279 if g_debug then
280 --
281 hr_utility.set_location(' Leaving:'||l_proc, 10);
282 --
283 End if;
284
285 End post_update;
286 --
287 -- ----------------------------------------------------------------------------
288 -- |-----------------------------< convert_defs >-----------------------------|
289 -- ----------------------------------------------------------------------------
290 -- {Start Of Comments}
291 --
292 -- Description:
293 -- The Convert_Defs procedure has one very important function:
294 -- It must return the record structure for the row with all system defaulted
295 -- values converted into its corresponding parameter value for update. When
296 -- we attempt to update a row through the Upd process , certain
297 -- parameters can be defaulted which enables flexibility in the calling of
298 -- the upd process (e.g. only attributes which need to be updated need to be
299 -- specified). For the upd process to determine which attributes
300 -- have NOT been specified we need to check if the parameter has a reserved
301 -- system default value. Therefore, for all parameters which have a
302 -- corresponding reserved system default mechanism specified we need to
303 -- check if a system default is being used. If a system default is being
304 -- used then we convert the defaulted value into its corresponding attribute
305 -- value held in the g_old_rec data structure.
306 --
307 -- Prerequisites:
308 -- This private function can only be called from the upd process.
309 --
310 -- In Parameters:
311 -- A Pl/Sql record structure.
312 --
313 -- Post Success:
314 -- The record structure will be returned with all system defaulted parameter
315 -- values converted into its current row attribute value.
316 --
317 -- Post Failure:
318 -- No direct error handling is required within this function. Any possible
319 -- errors within this procedure will be a PL/SQL value error due to
320 -- conversion of datatypes or data lengths.
321 --
322 -- Developer Implementation Notes:
323 -- None.
324 --
325 -- Access Status:
326 -- Internal Row Handler Use Only.
327 --
328 -- {End Of Comments}
329 -- ----------------------------------------------------------------------------
330 Procedure convert_defs
331 (p_rec in out nocopy pqh_str_shd.g_rec_type
332 ) is
333 --
334 Begin
335 --
336 -- We must now examine each argument value in the
337 -- p_rec plsql record structure
338 -- to see if a system default is being used. If a system default
339 -- is being used then we must set to the 'current' argument value.
340 --
341 If (p_rec.statutory_situation_id = hr_api.g_number) then
342 p_rec.statutory_situation_id :=
343 pqh_str_shd.g_old_rec.statutory_situation_id;
344 End If;
345 If (p_rec.processing_sequence = hr_api.g_number) then
346 p_rec.processing_sequence :=
347 pqh_str_shd.g_old_rec.processing_sequence;
348 End If;
349 If (p_rec.txn_category_attribute_id = hr_api.g_number) then
350 p_rec.txn_category_attribute_id :=
351 pqh_str_shd.g_old_rec.txn_category_attribute_id;
352 End If;
353 If (p_rec.from_value = hr_api.g_varchar2) then
354 p_rec.from_value :=
355 pqh_str_shd.g_old_rec.from_value;
356 End If;
357 If (p_rec.to_value = hr_api.g_varchar2) then
358 p_rec.to_value :=
359 pqh_str_shd.g_old_rec.to_value;
360 End If;
361 If (p_rec.enabled_flag = hr_api.g_varchar2) then
362 p_rec.enabled_flag :=
363 pqh_str_shd.g_old_rec.enabled_flag;
364 End If;
365 If (p_rec.required_flag = hr_api.g_varchar2) then
366 p_rec.required_flag :=
367 pqh_str_shd.g_old_rec.required_flag;
368 End If;
369 If (p_rec.exclude_flag = hr_api.g_varchar2) then
370 p_rec.exclude_flag :=
371 pqh_str_shd.g_old_rec.exclude_flag;
372 End If;
373 --
374 End convert_defs;
375 --
376 -- ----------------------------------------------------------------------------
377 -- |---------------------------------< upd >----------------------------------|
378 -- ----------------------------------------------------------------------------
379 Procedure upd
380 (p_effective_date in date
381 ,p_rec in out nocopy pqh_str_shd.g_rec_type
382 ) is
383 --
384 l_proc varchar2(72) := g_package||'upd';
385 --
386 Begin
387
388 g_debug := hr_utility.debug_enabled;
389
390 if g_debug then
391 --
392 hr_utility.set_location('Entering:'||l_proc, 5);
393 --
394 End if;
395
396 --
397 -- We must lock the row which we need to update.
398 --
399 pqh_str_shd.lck
400 (p_rec.stat_situation_rule_id
401 ,p_rec.object_version_number
402 );
403 --
404 -- 1. During an update system defaults are used to determine if
405 -- arguments have been defaulted or not. We must therefore
406 -- derive the full record structure values to be updated.
407 --
408 -- 2. Call the supporting update validate operations.
409 --
410 convert_defs(p_rec);
411 pqh_str_bus.update_validate
412 (p_effective_date
413 ,p_rec
414 );
415 --
416 -- Call to raise any errors on multi-message list
417 hr_multi_message.end_validation_set;
418 --
419 -- Call the supporting pre-update operation
420 --
421 pqh_str_upd.pre_update(p_rec);
422 --
423 -- Update the row.
424 --
425 pqh_str_upd.update_dml(p_rec);
426 --
427 -- Call the supporting post-update operation
428 --
429 pqh_str_upd.post_update
430 (p_effective_date
431 ,p_rec
432 );
433 --
434 -- Call to raise any errors on multi-message list
435 hr_multi_message.end_validation_set;
436 End upd;
437 --
438 -- ----------------------------------------------------------------------------
439 -- |---------------------------------< upd >----------------------------------|
440 -- ----------------------------------------------------------------------------
441 Procedure upd
442 (p_effective_date in date
443 ,p_stat_situation_rule_id in number
444 ,p_object_version_number in out nocopy number
445 ,p_statutory_situation_id in number default hr_api.g_number
446 ,p_processing_sequence in number default hr_api.g_number
447 ,p_txn_category_attribute_id in number default hr_api.g_number
448 ,p_from_value in varchar2 default hr_api.g_varchar2
449 ,p_to_value in varchar2 default hr_api.g_varchar2
450 ,p_enabled_flag in varchar2 default hr_api.g_varchar2
451 ,p_required_flag in varchar2 default hr_api.g_varchar2
452 ,p_exclude_flag in varchar2 default hr_api.g_varchar2
453 ) is
454 --
455 l_rec pqh_str_shd.g_rec_type;
456 l_proc varchar2(72) := g_package||'upd';
457 --
458 Begin
459
460 g_debug := hr_utility.debug_enabled;
461
462 if g_debug then
463 --
464 hr_utility.set_location('Entering:'||l_proc, 5);
465 --
466 End if;
467
468 --
469 -- Call conversion function to turn arguments into the
470 -- l_rec structure.
471 --
472 l_rec :=
473 pqh_str_shd.convert_args
474 (p_stat_situation_rule_id
475 ,p_statutory_situation_id
476 ,p_processing_sequence
477 ,p_txn_category_attribute_id
478 ,p_from_value
479 ,p_to_value
480 ,p_enabled_flag
481 ,p_required_flag
482 ,p_exclude_flag
483 ,p_object_version_number
484 );
485 --
486 -- Having converted the arguments into the
487 -- plsql record structure we call the corresponding record
488 -- business process.
489 --
490 pqh_str_upd.upd
491 (p_effective_date
492 ,l_rec
493 );
494 p_object_version_number := l_rec.object_version_number;
495 --
496 if g_debug then
497 --
498 hr_utility.set_location(' Leaving:'||l_proc, 10);
499 --
500 End if;
501
502 End upd;
503 --
504 end pqh_str_upd;