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