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